6
votes

I want to get unique values for specific tag of some metric. For example if I have metric 'metric_name' has tags 'tag_name1' and 'tag_name2':

metric_name{tag_name1='a',tag_name2='b'}
metric_name{tag_name1='c',tag_name2='d'}
metric_name{tag_name1='e',tag_name2='f'}

I want to get unique values of 'tag_name1' tag: a,c,e

Kind of like:

select distinct tag_name1 from metric_name
1

1 Answers

3
votes

TLDR;

Template with query label_values(tag_name1) would do the job.

More details:

By the prometheus tag I guess you are working with this db.

You can use the Grafana templating to get the unique values for specific tag of some metric.

Query is the most common type of Template variable. Use the Query template type to generate a dynamic list of variables, simply by allowing Grafana to explore your Data Source metric namespace when the Dashboard loads.

For example a query like prod.servers.* will fill the variable with all possible values that exists in that wildcard position (in the case of the Graphite Data Source).

So you can add template and query using label_values for Prometheus query in Grafana.