Dashboard filter for Graph

Hi all,

I want to use filtering on my monitoring dashboard by ip address of the machines where my services are hosted on. For example, i have two services Apache Storm and Zookeeper, that each are hosted on and I would like to show jvm_memory_bytes_used metric that i received via jmx from these services. But as i am receving it using jmx, i have instance label of this metric like (storm), (zookeeper), (storm), (zookeeper)
To make these labels more human-readable i show metrics in the following query:

label_replace(jvm_memory_bytes_used{area=~“heap”}, “instance”, “$1”, “instance”, “(.*):.*”)
and Legend format as: {{job}} {{instance}}

That perfectly works, metrics are showed like zookepeer, zookepeer, etc

But i want to filter my Graph by ip address, to choose only server and only this server’s metrics for service will be showed: zookepeer, storm in my example.
So i add $instance variable on my dashboard template as:
label_values(jvm_memory_bytes_used, instance)
and regex:
These operations add variable to my dashboard and i could choose servers as,
But choosing filters does not affect my Graph at all, memory_used metrics don’t choosing for corresponding server.

Please provide me with an answer, what am i doing wrong or maybe another solution for my case…

In your metric in graph you’ll need to filter by the template variable you’ve created, something like

metric{... instance=~"^$instance.*"}

See example https://play.grafana.org/d/000000063/prometheus-templating?orgId=1