I am hoping to use Grafana to create dashboards from data that is held on a local Postgres database. The Query Editor is working correctly and returning data as I would expect. However, I am struggling to plot this data in a graph.
One of my queries returns a list of items, and their corresponding count. I want the list of items along the x axis, and the count on the y - fairly standard stuff. I have selected ‘Graph’ as the panel type, but it would appear that this only likes to plot things when the x axis contains a time/date value. I have set the X-Axis mode to ‘Series’ as suggested in the docs, but am really struggling to get the graph to work at all.
Query:
SELECT COUNT(items) AS Count, items
FROM global
GROUP BY items
ORDER BY Count DESC;
Would really appreciate some help as how to get this working!
I also wondered how I could format the date/time x values in the UK format, namely DD/MM, rather than MM/DD. I have set the unit as locale format, which does not appear to have helped.
This is what I am hoping to plot:
Other things I have tried is also wrapping the query with the macro as follows:
SELECT $__time(observation_date)
and also
COUNT(date_trunc('day', observation_date)) AS metric
However these don’t seem to help, with the latter returning a Column metric must be of type char,varchar or text error.