Hello friends,
I’m using Grafana v10.3.3 on Windows and getting data from an InfluxDB.
My database stores an application login history data and I want to show it in grafana classified in three groups by hour range. 00:00 - 8:30am, 8:30am - 11:30am and 11:30am - 2:00pm) something like this:
I used this below query in the screenshot above
SELECT count(“Type”) FROM “ICAU” WHERE (“active”::tag = ‘True’) AND time >= ${__from}ms and time < ${__to}ms-15h30m GROUP BY time(1d)
and I used three queries in the bart chart graph with different time range to show what I want.
Issue: The query above works only with one day range selected, if I choose a range date for more than one day it does not work because the two vars ${__from} and ${__to} takes the two days range to do the calculation and then the query shows the sum of the values of the two days in that hour range. Example below
So as you correctly noted, the queries you wrote do not work for a range longer than one day. I am not even sure this is possible using InfluxQL.
Have you considered using Flux or SQL instead of InfluxQL? In Flux and SQL, I created queries that do an aggregation by the hour of the day (i.e. 24 bars representing 24 hours). Maybe you could modify these queries to reflect the 3 bin sizes that you specified (00:00 - 8:30am, 8:30am - 11:30am and 11:30am - 2:00pm)?
Here’s a blog post comparing the 3 languages. Here are the two bar charts that “bin by the hour of the day” and will change based on the Time Picker (7 days, 30 days, 6 months, 1 year, etc.)
I appreciate your answer. I followed your suggestion to try with Flux, I did not get it done not because is not possible, it was because I’m not familiar with Flux, this is what I got so far:
Workaround: However I did find a workaround and I will see the behavior in the next couple of days. I owned the data base so I extracted the hour and minute value, concatenated them in a new column in the measurement and then filter the values between the range I’m expecting to graph in my query. I’ll see how it works.