Janik Vonrotz


1 min read

Add Prometheus instance variable to Grafana query

Prometheus stores the instance or host name for every metric. If you want to filter your dashboard data based on the instance name you need a Grafana variable.

Open the Grafana, select your dashboard and navigate to Settings > Variables. Create a new variable:

Name: isntance
Typoe: Query
Lable: Instance
Data source: Prometheus
Query: label_values(instance)
Include All option: true

Check if the preview returns the instances.

Next open a panel and insert {instance=~"$instance"} into your metric like this:

Now all the panel data will be filtered by whatever is set for the variable.

Categories: System Engineering
Tags: grafana , prometheus
Improve this page
Show statistic for this page