influxdata / flux

Flux is a lightweight scripting language for querying databases (like InfluxDB) and working with data. It's part of InfluxDB 1.7 and 2.0, but can be run independently of those.

Home Page:https://influxdata.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to filter by the size of keys()

RemHero opened this issue · comments

My requirement is to only find the sequence that contains the exact tag.

For example, there are two sequences, seriesA {t1=v1}, and seriesB {t1=v1 and t2=v2}. Now I want to use an expression to find sequences that only contain {t1=v1}, that is, seriesA, without finding seriesB. I found that using ordinary filter statements cannot meet the requirements, so I want to implement it through the keys () statement, which means that I filter out redundant sequences by judging the length of keys (). How should I write query expressions?

This issue has had no recent activity and will be closed soon.

I am also interested in this!

@RemHero @LarsStegman You should be able to do this with just normal filter expressions:

from(bucket: "example-bucket")
    |> range(start: -1d)
    |> filter(fn: (r) => r.t1 == "v1" and not r.t2 == "v2")

That does not do what we want. What if there is a third tag that we do not know the name of? We cannot write a filter for it, so we need to specify some way that we want exactly the tags we describe and no others.

This issue has had no recent activity and will be closed soon.

Not solved I think

This issue has had no recent activity and will be closed soon.