Postgresql query + Graph


I don’t know if I’m using correctly the datasource of postgresql but:

  • I’ve ad a graph with a a query, for example " select count(*) from my_table" .

This returns the correct value, wich changes trought time… But grafana is not keep track of the changes so it cannot produce the graph.

When i choose to show the values min max avg current and total, they are always the same trough time.

Thank you

That query does not return a time column

hello, thank you for the reply

I added (NOW() ) in my actual query:

SELECT NOW () as time,
round( (blks_hit :: NUMERIC / (blks_hit + blks_read) :: NUMERIC) * 100,2) AS read_hit_percentage
blks_hit + blks_read > 0 AND datname=‘mydatabase’

it does not give me any error, but still does not produce the graphic. What Am Im missing here?


NOTE: if I add a panel (Table) it only produces 1 row every refresh.

thank you

Grafana does not collect metrics or remember metrics. Grafana only does visualization you need some other software (for example collectd or telegraf) to do the collecting.

Hello, thank you for the reply.

I already use zabbix integrated with grafana, but when I saw this postgresql datasource directly integrated with grafana, making it possible to do whatever query I wanted, it’s a all new level, in terms of flexibility.

So this makes me wonder what’s the point of having this datasource if we still need an intermediate to do metrics?

With zabbix, using “userParameters” in the agent side I can perform any kind of Query.

I thought by using directly the postgresql datasource in grafana iI could directly access the same data (wich I can) but it is only usefull to “print” current values. To build a simple graph over time ( for example like an hour) it can’t because it does not store the past values.

I think this datasource as the potential to be great by allowing the flexibility to query any postgres DB we want for monitoring… But it could collect values, this could be store e grafana DB no?

Thank you