Multiple data: label or field? (from a Grafana perspective)

I have an experimental setup with a many sensors. I put all sensors in the same measurement to make it more straightforward to plot several of them in the same graph. Each sensor has an ID and all values are labeled with the sensor ID.

Starting from the default query, all the user has to do is add a GROUP BY ID operator and specify the sensor IDs he wants as WHERE filters.

Now, I’d like to add a dimension to that. I want to clean-up data using an external algorithm and add the clean data to the database. I’m wondering how to separate the clean data from the raw data.

I’d like to keep everything under the same measurement, as said above.

The two options I see are labels and fields:

  • create a new label to distinguish raw and clean data
  • use a field for raw value and a field for clean value

1/ Using raw/clean labels

I guess this will work. However it might make the queries a bit more cumbersome as each sensors will have to be filtered not only by ID but by ID and status label:

WHERE ID=T1 AND status=clean OR ID=T2 AND status=clean

I’d like this factorized as:

WHERE (ID=T1 OR ID=T2) AND status=clean

To do that, I need to switch to manual query edit.

I doesn’t look like there is a plan to add a parenthesis feature to the GUI. Could this be a relevant enhancement request?

Is there another way to achieve what I’m trying to do?

2/ Using raw/clean fields

I could use different fields for raw and clean values.

It would make it possible to get either all raw values or all clean values or both:

WHERE ID=T1 OR ID=T2 SELECT field(raw)
WHERE ID=T1 OR ID=T2 SELECT field(clean)
WHERE ID=T1 OR ID=T2 SELECT field(raw) field(clean)

However, I wouldn’t be able to get the raw value for one sensor and the clean for the other in a single query. I just realized it can still be achieved in two separate queries so it might not be such a blocker after all.

I guess it depends on how often I need to query “raw T1 + clean T2”. Overall it looks less cumbersome than 1/ in the most frequent case.

Any advice welcome.

I chose solution 2/ because I will rarely need to work with both raw and clean data in the same query.

On second thought, I’m thinking I should have used two different measurements. It wouldn’t really be more difficult to query in Grafana (use two queries when mixing both raw and clean). And it would be easier to delete clean values, because it is not possible with Influx to delete a single field from a measurement, so deleting a field involves deleting the measurement then recreating the other fields.