I have a dynamic amount of buckets that i want to list, i only want to list the buckets that contain a specific value from a field.
So a more specific explanation here:
I have x amount of bucket, each bucket have a field called software, i want to list only the buckets containing a certain value in software.
Example:
if bucket == (
<bucket>
<Measurement>
<Field> == "Software"
<_value> == "test" ) {
list.append(bucket)
else {
continue
}
I only need the names of the buckets to show them in a list to show the graphs with data from that system.
It's used in a dashboard variable where i now use:
buckets()
And the chosen system is in the queries in the dashboards panels.
The thought is that each dashboard is one software so we have all the systems/buckets with that software to choose from in the list.
A system can change software and some other factors make me want to have the system as the bucket instead of the software.
I have tried everything i can find on google and youtube but none give the answer to how to query a dynamic amount of buckets/all buckets
I found a way if i use the regex either in the query with 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))
Or just setting a regex in Grafana on the dashboards variable regex box