How to check if a specific tag exists in a measurement using flux language? My influxdb version is 2.0.
How to check if a specific tag exists in a measurement using flux language? My influxdb version is 2.0.
simple you need to add a filter for the tag name you need to filter to your flux query. let's say the tag name is "tag_name":
|> filter(fn: (r) => exists r.tag_name)
this will filter any undefined or "unset" tag.
(answering for my usecase, since no details were provided)
TL;DR: use the exists operator.
Imagine a dataset which has this old tag, which we don't care about anymore, and we want to filter out those records when archiving:
option task = {
name: "15min_archive",
every: 1w,
}
from(bucket: "mybucket")
|> range(start: - duration(v: int(v: task.every) * 2))
// this:
|> filter(fn: (r) => (exists r["stupidOldTag"] ) == false )
|> aggregateWindow(every: 15m, fn: mean)
// ...
note: the ==false because not is apparently not a thing yet.