Best practice for handling sensor threshold values

schema
influxdb
#1

Hello,

Is there, and if yes what is the best practice/recommended way to store threshold values as part of a measurement.

Let me give you an example what I want to achieve:
I have temperature sensor data coming in:
timestamp, location, … min_val, max_val, … value
In my query I want to check, in the where clause, if the value is within boundaries (alert) (value <=min_val and value >=max_val). If I store the min_val and max_val as tags it is treated as a string so doing the test as described doesn’t work.
I can of course, make the min_val and max_val fields (instead of tags) and I suppose the where clause then will pass. But is this the way to do it? I thought tags are the meta data for the timeseries/measurement, and aren’t min_val and max_val no meta-data?!
Any help/recommendation very much appreciated.

Thanks.
Guy

#2

@gdillen There is no recommended best practice for this. A couple of things to consider when making this decision:

  • Tags are always held as strings so if you need to do math on the values (val/max_val as utilzation) you would need to store them as fields.
  • Storing the same value over and over again as a field is really inexpensive on disk, but will require more bandwidth.
  • Seems like you are trying to build an alerting system. We have already done a bunch of the hard work for that in Kapacitor. There is even a UI for creating these alerts in Chronograf.

Does this answer your question?

#3

@jackzampolin Thanks for the answer, I’ll threat the values as fields so I can compare. I’m trying to display in a dashboard (Grafana) the measurements that are out of threshold values. As an alternative, can Chronograf be used on macOS for development?
Thanks.

#4

@gdillen Absolutely! Might want to check out our new sandbox for local development. You can also follow this guide to get started.