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
To create a new variable, go to your Grafana dashboard settings, navigate to the Variable option in the side-menu, and then click the Add variable button. In this case, we use the Query type, where our variable will be defined as the result of an SQL query. Under the General section, we name our variable route .
In Grafana, you can configure New Relic as a Prometheus data source. Not only that, within Grafana you can query metrics stored in New Relic using the PromQL query language.
Go to the tab Transform , select Add field from calculation , and chose Mode : Binary operation . Then you can select your two query results, choose + as operator, give an alias and choose to hide the inital fields if you want.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With