1

I query all measurements from Influx database like so:

http://localhost:8086/query?pretty=true&db=boatdata&q=SELECT value FROM /.*/ LIMIT 1

Works fine. However, instead of LIMIT 1 I need to get values for all the measurements where value from one measurement=x, so I’d expect something like SELECT value FROM /.*/ WHERE measurement1.value=x but it doesn’t work. I hope it makes sense. Any idea how to make it work? Thanks.

...to explain it better: in the first query (http://localhost…) I listed in this post I get a 1 record for all the measurements. But I want to get 1 record for all the measurements where value from measurement1 (one of the measurements) equals X.

kaios
  • 395
  • 1
  • 4
  • 13
Sam Zadworny
  • 23
  • 3
  • 12

1 Answers1

3

This is impossible using InfluxQL. All measurements you ask are different series of data - so they are not grouped together in one table. Idea of InfluxDB is that measurements are separate "tables" which are indexed by time and tag keys. I suggest you change your database architecture by writing values into different value fields. You should have your data in one measurement to make query like you want. You can move all your data from other measurements to one measurement for example by:

select "value" as "value1" from "measurement1" into "measurement" group by *

For each "measurement1" moved into "measurement" which will collect many value fields. Then you will be able to make a query:

select * from "measurement" where "value1"=5

The query above should give you all value fields moved into "measurement" with the same timestamp where field "value1"=5. Tip: If you have value1,value2,value3 in your measurement then you can use regex like:

select /value/ from "measurement" where "value1"=5

To avoid receiving tag key values or field values which you do not want.

Crashtein
  • 261
  • 2
  • 8
  • My understanding is, that series ("tables") are identified by the tag-set and the measurement name. Means that if a datapoint has different tags, it will be put into a different series. Since it is possible to be flexible when querying tag values, I would expect the same flexibility to exist on measurement names. – sezanzeb Apr 26 '23 at 10:43
  • Ah, sorry, I misunderstood the question because I was just flying over tihngs. While it is definitely possible to select from multiple measurements (https://stackoverflow.com/questions/47900949/select-from-multiple-measurements), the question was about querying tags depending on the measurement name. – sezanzeb Apr 26 '23 at 10:49