I have a measurement within a bucket. The measurement has three possible tag keys and only one field. I have created a value at every possible combination of tag key and value… starting with no tag keys and ending with all three tag keys. the schema looks something like…
Measurement1,Tag1=A,Tag2=B,Tag3=C,Field=F – again, containing any combination of Tag1, Tag2, and Tag3
When I try to query for a value of a series that does not contain all three tag keys… for example – a series that does not contain Tag2.
from(bucket: “MyBucket”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == “M1” and r.Tag1 == “A” and r.Tag3 == “C” and r._field == “F”)
|> last()
The returned values will be for the series requested (series with only Tag1 and Tag3), but also any series containing r.Tag2 since I am unable to filter that out (wont have knowledge that that tag key exists at runtime).
Is there any way around this issue? Ive also noticed that if I use the flux query influx provides to return all possible tag keys (that way I could have knowledge of all possible tag keys at runtime) on a measurement, no tag keys are returned for this measurement. Why wont this call return any tag keys when there are multiple tag keys on this measurement?
import “influxdata/influxdb/schema”
schema.measurementTagKeys(bucket: “MyBucket”, measurement: “Measurement1”)
Table and query from live results – Only Tag A and C were wanted. Tag B was brought back due to not being able to filter properly.
from(bucket: “DomsDB2”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r._measurement == “M1” and r.A == “V1” and r.C == “V3” and r._field == “F”)
|> last()
#group | FALSE | FALSE | TRUE | TRUE | FALSE | FALSE | TRUE | TRUE | TRUE | TRUE |
---|---|---|---|---|---|---|---|---|---|---|
#datatype | string | long | dateTime:RFC3339 | dateTime:RFC3339 | dateTime:RFC3339 | double | string | string | string | string |
#default | _result | |||||||||
result | table | _start | _stop | _time | _value | A | B | C | _field | |
0 | 2020-10-08T17:12:58Z | 2022-01-19T18:17:58.102Z | 2021-01-25T14:21:40Z | 123 | V1 | V2 | V3 | F | ||
#group | FALSE | FALSE | TRUE | TRUE | FALSE | FALSE | TRUE | TRUE | TRUE | TRUE |
#datatype | string | long | dateTime:RFC3339 | dateTime:RFC3339 | dateTime:RFC3339 | double | string | string | string | string |
#default | _result | |||||||||
result | table | _start | _stop | _time | _value | A | C | _field | _measurement | |
1 | 2020-10-08T17:12:58Z | 2022-01-19T18:17:58.102Z | 2021-01-25T14:21:40Z | 103 | V1 | V3 | F | M1 | ||
![image | 690x216](upload://2D9YBXnRy8XV3CYMzKTZ38RVZzR.png) |