1

I have a bucket with the raw data of several sensors, things like temperature, air pressure and etc. The sensors don't send their data at the same time, which means that a given timestamp might have several data points from various sensors or just from just one.

Each reading is tagged with the ID of the sensor it comes from. I need to get the Last() reading from a given number of IDs. When I try this code:

select last(Temperature) from raw_measure where ID =~ /4372502|4399699|4406512|4407840/

instead of returning the last Temperature observation of each ID, it returns the most recent temperature timestamp of the whole group.

How can I get the last reading of each ID in a single query?

0
1

I found the solution. All you need to do is add an ORDER BY with the TAG field. So the end query becomes:

SELECT last(Temperature) 
FROM raw_measure 
where ID =~ /4372502|4399699|4406512|4407840/ 
ORDER BY ID

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.