Best approach for storing & querying state change

Looking for some advice on how to best handle this…

We have TRUE/FALSE sensors on a variety of equipment and are storing any change in state. See below.


The above is from Grafana and InfluxDB 1.8, where we store the boolean status info every minute, which to me seems ridiculous because the state only changes ~5% of the time.

We are currently planning our migration of all data to Influx 2.0 and re-writing our queries in Flux. It seems it would be better to store ONLY the changes in state. The goal here is to use Grafana to display only the changes in state. Surely someone has crossed this bridge before?

If you’re already capturing TRUE\FALSE for the state changes in Influx then in Grafana 8 there is a “State Timeline” graph you can use to graphically display the state changes based on that column, which looks similar to your image.

Yes, but Grafana 8’s state timeline (which I am indeed using in the screenshot) does not display the state on the graph (red or green, in my case) unless there is a data value from InfluxDB within that time picker window. So if I am viewing last 1 hour of data, but the last state change was 3 hours ago, it will appear as blank / black in that graph. If the last state change was 45 minutes ago, then it WILL appear.

I am trying to avoid saving the state every 5 minutes or so, since this is the minimum time window we would normally be viewing. My hope was that there is a cleaner method to handle this.