Can i filter buckets() to show only buckets with part name or containing a certain value on a measurement

  • What Grafana version and what operating system are you using?
    Grafana * v8.5.2 (90701be19)
    Indlux DB v2.2.0
    Linux: Ubuntu 20.04.4 LTS

  • What are you trying to achieve?
    I have a variable to choose source of my data, i use Buckets() but i want to filter this to buckets that either matches a string with wildcard (*) or have a certain value in one of the measurements.

The amount of buckets availible is dynamic since i keep adding buckets with a script so the query must be dynamic to include all buckets in the search for matching ones.

  • How are you trying to achieve it?
    I have tried all i can think of but it’s really hard to find guides and sources on flux to achieve what i’m trying to do.

  • What happened?
    I get either all or exact match on bucket if i set a name instead of Buckets()

  • What did you expect to happen?
    I want to select only buckets whos name starts with the string provided OR
    I want to select only buckets that contains a certain value in a specified measurement
    Either one of the above or both is ok.

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No it’s a Flux either restriction or ignorance from my side and i can’t seem to find guidance to learn what i need

  • Did you follow any online instructions? If so, what is the URL?
    I’ve scoured google for this matter but i can’t seem to find what i’m looking for

It is fine to create a new bucket with all the bucket names as a measurement and then select from the names with a wildcard from that bucket if this is possible

Maybe by using one of the Flux Standard libraries?

would be interesting to know what kind of object buckets() returns

@TimmyOl Welcome to the Influxdata community.

To achieve the required behavior you can use the regexp package.

import "regexp"

// ending with abc
re = regexp.compile(v: ".*abc")

data = from(bucket: "example-bucket")
    |> range(start: -1h)
    |> filter(fn: (r) => regexp.matchRegexpString(r: re, v: r._measurement))