Easy Question - filter schema.measurements

I have this to get a list of my measurements but I want to populate a dropdown in Grafana with just a few. How do I filter the results?

schema.measurements(
bucket: “mybucket”
)

Somehow I want this added in there: |> filter(fn: (r) => r["_measurement"] == “RTPLPROHISTORY.FIT_0300.SCALED”

but I’m not sure how to filter the results of the output… thanks for any help. I googled and googled…

I don’t now if you still need help with this, but if anyone has the same Problem and found this question, I’ve recently posted a very similar question and found an answer to it: https://community.influxdata.com/t/schema-filter-fields-by-specifying-a-tag

While the “Explore your data schema with flux” page only presents pretty basic use cases, the actual schema.fieldKeys() documentation shows that a predicate function can be specified as an optional argument in the function parameters. After finding the definition and the usage of predicate functions in flux, I added a predicate function to only show fields with a certain “device” tag value:

import "influxdata/influxdb/schema"
schema.fieldKeys(bucket: "example-bucket", predicate: (r) => r.device == "my-device-type")

This solved my problem.

1 Like

schema.fieldKeys allows the use of predicate to filter, but schema.measurements doesn´t.
I understand the only way is to query based on other criteria and then remove the result columns except for measurements. Something like:
from(bucket: “yourbucket”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“some tag”] == “some tag value”)
|> drop(columns: [“col1”, “col2” … , “_field”, “_value”, “_time”, “_start”, “_stop”]) —> all excpetc measurement
|> unique(column: “_measurement”)
And this will list all measurements for r[“some tag”]