Search code examples
influxdb

InfluxdB Flux Query Measurements That Contain a Substring


I am using InfluxDB's Flux query language to filter by measurement names. I want to know if it is possible to query for a measurement that contains a substring? For example if I have the measurement name “foo_bar” can I use a filter to look for any measurement that has substring “bar”? I tried the below and it did not work. Alternatively I can use regex but want to know if this function should work?

|> filter(fn: (r) => strings.containsStr(v: r._measurement, substr: "bar")

Solution

  • Try

    |> filter(fn: (r) => strings.containsStr(v: r._measurement, substr: "bar") == true)