Showing multiple sensors data on the same measurement

Hello everyone,

I receive data from multiple sensors which are distributed in different places.
As i’m not yet aware of how to use the Indluxdb2 dashboard, i store the data also on the old Influxdb 1.8v, and it looks like the following:

my question is:
How can i show the same data (the same way) on the influxdb2 dashboard without having to use the aggregation functions(as they cause errors with the names in red(strings)?

I would like to be able to download a CSV file with “Correctly tabled” data (not mixed measurements - like all the temperatures, measurements from all the places are stated together).

Thank you in advance.

@Mr_Influx What’s your current InfluxQL query that you’re using to get this data?

Hello Scott, thank you for your reply, the influxQL query was:

**

use DataBase_1
select * from measur_1 limit 50

**

When i try to show the same data on the Influxdb2 dashboard, i get all the sensors data from all the sites mixed together, hence the graph doesn’t represent the real data of any of the sites.

Kindly, i would like to know how i customize the query so I’m able to query a specific site or even better a specific sensor inside a specific site.

Ok, thanks for the screenshot. It definitely helps identify the problem. Are you meaning to store device_id and ____ Name as fields? I would expect these to be tags to get the data to graph they way you’re hoping.

honestly, i don’t know how to define their type as i send them from Node-Red as variables, but if converting them into tags would solve the problem then what should i do to make them tags?

I’m trying something like:

from(bucket: “novabucket”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == “measur_1” and r[“_field”] == “_Name”)
|> filter(fn: (r) => r[“_field”] == “humidity” or r[“_field”] == “battv” or r[“_field”] == “Temp”)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: “mean”)

This script alone returns the same (mixed) data as in the screenshot above,
however, once i add the condition(which is one of the sites names):

and r[“_sitename”] == “vi_20d”

to the 1st filter, i get no graph, just “no result

There is information on writing values as tags in the InfluxDB Node documentation. Setting “metadata” like device ID and name as a tag will make your data easier to query.

Thank you Scott, i started to search the documentation but i was confused about which section should i search (the word “tags” don’t have much) i’ll check what you suggested instead.

Here’s some information about designing schemas for InfluxDB: InfluxDB schema design | InfluxDB Cloud Documentation

In the InfluxDB node (Node Red) documentation, you separate fields and tags in to separate objects as part of the output node payload array. The first object in the array is all the fields. The second object is all the tags associated with the point. Here’s the example they provide:

msg.payload = [{
    intValue: '10i',
    numValue: 12,
    randomValue: Math.random()*10,
    strValue: "message2"
},
{
    tag1:"sensor1",
    tag2:"device2"
}];
return msg;

Scott’s post above is exactly 100% correct. That is how I send data via Node-RED to Influx v2.3

@Mr_Influx post back if you get stuck. Also, create a test bucket first to make sure it works before using the “real” bucket.

1 Like

It’s much better now

but as i don’t see any graph at the moment, i’m not sure if is it because the new data is too few or i should change something, i’ll wait 24h and try to get the mean curve.

1 last question, is it possible to modify the old data(not tagged) or I’ve to ignore it and start again?

Thank you so much Scott.

Another question please, how i can rearrange the data based on the received time of influx?

I tried to use the function “sort” but i think it’s related to sorting the measurement values (the temperature in this case).

Is it possible to modify the old data(not tagged) or I’ve to ignore it and start again?

With the way the data was structured, unless every sensor sent data in at different times, there isn’t a way to accurately associate the field and tag values that should be tied together. I’m afraid you may just have to start again.

How i can rearrange the data based on the received time of influx?

By default, InfluxDB returns data sorted by time. You shouldn’t need to re-sort the data. When you use the sort() function from the functions selector, it doesn’t actually let you set the column(s) to sort by and the default is ["_value"]. This is why it appears to be sorted by value.

To help see that data as it is, don’t apply any aggregate function. If one is selected, deselect it. This will return your data as is without any aggregation or modification.

1 Like

With the way the data was structured unless every sensor sent data in at different times, there isn’t a way to accurately associate the field and tag values that should be tied together. I’m afraid you may just have to start again.

I think i’ll start again, I’m keeping an additional version of the same data on the Influxdb 1.8, so maybe i can manipulate it and immigrate it to V2.

To help see that data as it is, don’t apply any aggregate function. If one is selected, deselect it. This will return your data as is without any aggregation or modification.

But the platform doesn’t allow me to do that, every time i try to deselect the aggregation function, it complains like:

image

also for the “AUTO” for the aggregation functions, i can’t deselect them. I must choose one.

I’m not seeing this behavior. What version of InfluxDB are you using? 2.4? This is the behavior I see in 2.4:

Kapture 2022-10-27 at 08.24.40

I’m running the InfluxDB v2.4.0 as a container inside the RPI, and the behavior for me is as i mentioned, in fact, this is the main reason why i was looking to change the data that contain strings as the aggregation functions(which must be applied in my case) throw an error for the strings data.

This is what happens when i try to deselect the mean box:

Well that’s frustrating. With your current selection, just click Script Editor to switch over to the raw Flux query and delete the line with aggregateWindow(). That will return the data as it is.

Yes, this works

but i must reselect all the tags and the fields and comment the line every time i want to check the data.

You can add this query as a cell on a dashboard and use the dashboard to view the data rather than going through the data explorer every time.

1 Like