# Annotation query from postgresql not showing up in graph

**URL:** <https://community.grafana.com/t/annotation-query-from-postgresql-not-showing-up-in-graph/3972>\
**Category:** PostgreSQL\
**Tags:** postgres\
**Created:** [November 23, 2017, 8:53pm UTC](https://community.grafana.com/t/annotation-query-from-postgresql-not-showing-up-in-graph/3972 "2017-11-23T20:53:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![grassu](https://avatars.discourse-cdn.com/v4/letter/g/aca169/32.png) [@grassu](https://community.grafana.com/u/grassu)\
**Post date:** [November 23, 2017, 8:53pm UTC](https://community.grafana.com/t/annotation-query-from-postgresql-not-showing-up-in-graph/3972/1 "2017-11-23T20:53:03Z")

</div>

Hello,

I’ve only recently started using grafana (4.6.1). Cool project. I use PostgreSQL as the only data source. Currently I am trying to load annotations via an PostgreSQL query. For this purpose, I have created and activated an annotation query that looks like this:

SELECT  
$\_\_time (startdatetime),  
‘Stationbook’ as title,  
notation as text,  
tags  
FROM “data”. grafana\_stationbook  
WHERE $\_\_timeFilter(startdatetime)  
order by startdatetime;

The query would return the following values:

| time | title | text | tags  
| 2017-11-23 17:25:00 | Stationbook | Problem mit No2 | PID170,Reparatur,Sonstiges  
| 2017-11-23 19:41:00 | Stationbook | Test annotation2 | PID167,Alarm H2,Alarm O2  
…

Now my questions:  
What must be done to display the anotations in the graphics? At the moment, nothing is showing up.  
Can annotations be linked to specific data series using the tags or are all annotations always displayed in the graphics? E.g. I would like to link the tag ‘PID171’ to graphicseries with ID 171.

Many thanks in advance,  
Christian

---

<div class="post-metadata">

**Author:** ![svenklemm](https://avatars.discourse-cdn.com/v4/letter/s/e56c9b/32.png) [@svenklemm](https://community.grafana.com/u/svenklemm)\
**Post date:** [November 24, 2017, 4:44pm UTC](https://community.grafana.com/t/annotation-query-from-postgresql-not-showing-up-in-graph/3972/2 "2017-11-24T16:44:21Z")

</div>

For annotation queries you need to return unix timestamps in the time column.  
The following should work:

```sql
SELECT
extract(epoch from startdatetime) as time,
'Stationbook ' || notation as text,
tags
FROM “data”. grafana_stationbook
WHERE $__timeFilter(startdatetime)
order by startdatetime

```
