I’m trying to find the best way to store the units of a sensor in InfluxDB V2.0.
From what I understand if I store this in a tag then I have repeat the units (i.e. Bar / Percent etc) each time I store a data value. However, the datasource (MQTT) doesn’t ‘know’ what units the sensor uses, so it can’t do this.
Instead I want to store the units only once. After that I only want to send the measurement name and value.
Is there a way to achieve this in InfluxDB V2.0 or do I need a (SQL) separate database for that?
P01 is in BarA → Store this once
P01 = 10.2 → Store value only, not the units.
P01 = 10.3
P01 = 10.4
P01 = 10.3
Thanks for your reply!
That is what I am doing now. But Grafana (that is what I’m using to display a graph or table) doesn’t know the units either. I need to store the units so they can automatically be retrieved when showing the measurement in a graph or table.
Another thing is that I want to be able to filter on units so the user can, for example, only select temperatures or pressures.
I suggest you show us the query you’re using in Grafana so that we can better
understand why it can’t just select temperature when that’s what should be
displayed, or pressure when that is what should be displayed.
I use InfluxDB with Grafana and I’ve never found a need to store units in
Influx, just values. Grafana selects which (sorts of) values it needs simply
by doing “the appropriate query”.
The latter builds a list of sensors that the end-user can choose from that will be rendered in the graph. I want to limit the query output to a limited set (say: temperatures and pressures only). To do that I need to know what units the sensor uses. Hence my question.
Another reason to add units of measurement is that with large numbers of sensors it becomes increasingly difficult to know (remember) what the units are.
For example: Butter can be measured in kg’s, liters or number of packs. So if the measurement says “15” which one is it?
Grafana has the option to do a transformation “config from query results,” which solves this problem kind off. When using it with influxdb I found that you first have to use the transform “labels to fields”.
I am doing the same thing: creating one large graph panel where the users can combine fields from the database to do some analysis. However, this indeed gives the problem that many different measurements come in all different units and you can’t configure them all in the panel as new measurements are added weekly.
Must say I was a bit optimistic. While the combination of the 2 transformations should do the job, the “config from query results” is still in Beta and does not seem use the output of the first transformation.
I also tried testing with returning multiple fields, but this makes it even more confusing.
Seems like the config from query result has to be configured for each of the returned fields, which all have the same query name.
This topic shows the problem I am also having by first doing another transformation.
Hope this config from query feature gets an update soon.