I have sensor data in my InfluxDB. The sensor posts a 1 or 0, depending on the measured status. Now I want to display in my Grafana (8.2.3) the duration the sensor is 1. So, if the sensor is 6 minutes =1 during one hour, I want to see 10%.
I was googling around, but it seems I miss a certain keyword to have success. Even reading and searching the forum for some time did not enlighten me.
Can someone provide me with they right keyword or link or short explanation what too look for, how to achieve that goal?
What you describe is certainly possible. Can you first clarify if you are using InfluxQL or Flux language to write your queries?
If InfluxQL, then one solution would be something like this:
Query A…SELECT statement that contains a COUNT of ALL values over the given time window
Query B…SELECT statement that contains a COUNT of ONLY VALUES = 1 over the given time window
QUERY C…divides B by A
Make query A and B not visible on the chart, but make C visible as a % value in a Stat panel
I am a beginner in Grafana, but SQL (mssql, postgresql, …) is my bread & butter during the dayjob. I get the overall picture of your idea. However, is COUNT the right function for this? I do not know about InfluxQL very much, I admit.
Hi Peter. OK, thanks for explaining further. So as you correctly pointed out, you need the total duration (in seconds) of the timespan and also the duration (in seconds) in the same timespan where status = 1. I think this can definitely be done in InfluxQL.