I have a Grafana dashboard that displays Prometheus metrics for two AWS instances. I have a dashboard variable defined that returns the instance IDs I am interested in. For an "All" option I am using ".*"
. I match the resulting instance ID in my panel queries with query{instance_id=~"$instance_id"}
.The query involved in defining that variable is similar to this:
label_values(is_foo, instance_id)
That query works and gives me a nice way to select instances from a drop down menu on the dashboard.
Now, one instance returns 1 for is_foo
and the other returns 0. What I am trying to achieve is a way to refer to the instances with names foo
(for when is_foo
is 1) and bar
. Preferably there would be a drop down menu with names foo
and bar
and an "All" option, similar to what exists now. In the legends I would like the names to appear as well. Basically I am looking for a way to alias the instance IDs with pretty naming.
I have tried defining custom variables, for example foo_id
with query_result(is_foo==1)
and then assigning these to a custom map variable, foo : ${foo_id}
but the foo_id
variable will not expand. Is such a thing possible? Can custom variables be chained together?