Number of records per hour

What Grafana version are you using?
6.1.4
What datasource are you using?
postgresql 9.6

What OS are you running grafana on?
ubuntu 18

I am trying a graph using a postgre database. I have many records with its timestamp and I would like to make a bar graph with a count with the number of records grouped by hours.
I have got a nice graph but it does not give the expected results. I have something like this:

SELECT
__timeGroupAlias(timestamp,__interval),
count(id) AS “nids”
FROM table
WHERE
$__timeFilter(timestamp) AND
column= ‘Column’
GROUP BY 1
ORDER BY 1

format as Time series

Hi,

Your query looks good, what do you have? And what do you expect?

To achieve what you want, you also need to set the Min time interval option (just under the query) to 1h and set the Draw Modes to Bars (in the Visualization tab)

Thanks for answering Agnestoulet1, I am going to show the result and the records that I have in my database:


and these are my consulted records
image

I do not understand well why the bars do not occupy the entire space of an hour but the strangest thing is that the results are not good, it should start showing bars at 08:00 → 09:00 but I don’t see anything and the rest do not agree with the data. I have made sure and it is these records that I consult

this work for me

SELECT
$__timeGroupAlias("timestamp",1h),
count(id) AS “nids”
FROM table
WHERE
$__timeFilter(timestamp) AND
column= ‘Assistance Diag 24 France’
GROUP BY 1
ORDER BY 1
1 Like

109/5000

it’s true the query works! I just saw that the timezone is wrong, but in my other charts it’s ok

1 Like

Thank you very much. This worked for me