Reputation: 401
Is it a requirement that you must use a time or datetime column in postgres to pull metric's on a Grafana dashboard?
I ask because I have a column just with a date only and I'm unable to show metrics base on dates only. Unless I am missing something in the documentation. Postgres in Grafana
If anyone has any helpful information, it would be greatly appreciated. All I need is just a starting point. I am a new user to Grafana and I'm trying to figure this out.
Upvotes: 0
Views: 5331
Reputation: 1500
According to documentation:
If you set
Format
as toTime series
, for use in Graph panel for example, then the query must return a column named time that returns either a sql datetime or any numeric datatype representing unix epoch in seconds.
So, all you need is to convert your column with date to unix epoch and name it as time
. You can do it yourself or use macros provided by grafana (see docs) for convertion which are expanded into native postgres expressions. It is also helpful to look at 'Generated SQL' to see the actual query sent to database.
Upvotes: 1