Hello all.
In my bucket, I have 2 measurements, Sensor 1 and Sensor 2. (The sensors are multi-sensors)
These sensors are the exact same just placed in different areas, so they have the same fields. (temp, light etc…)
What im trying to accomplish is a dashboard with all the fields and then I can just switch the measurement from sensor 1 to sensor 2 and it will switch the measurements accordingly.
How do I accomplish this? I am a noob
Hi @subwayfootlong, not a noob question at all.
I would create a dashboard variable called measurments
like so:
import "influxdata/influxdb/schema"
schema.measurements(bucket: "INSERT_BUCKET_NAME")
Then within your dashboard flux. You call your variable like this:
from(bucket: v.bucket)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == v.measurments)
1 Like
Amazing @Jay_Clifford !
Now Im a step closer to not being a noob.
However, in my case, I wasnt trying to change buckets so my flux Query would be (For anyone strictly following this forum post )
from(bucket: "INSERT_BUCKET_NAME")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == v.measurments)
But you opened my eyes to new possibilities of the dashboard that I can build! Time to get my hands dirty with variables!
1 Like
If I would like to change buckets too, I know I have to create another variable called buckets but what would that variable contain?
I tried
schema.measurements(organization: "INSERT_Organization_NAME")
But that seems super wrong.
Hi @subwayfootlong,
Great to see your on your way! To get a dynamic list of buckets you can create the following variable query:
buckets()
|> filter(fn: (r) => r.name !~ /^_/)
|> rename(columns: {name: "_value"})
|> keep(columns: ["_value"])
2 Likes