Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query label_values not found in Prometheus [closed]

In the Grafana documentation, I found that I should be able to query my Prometheus server for all instances delivering monitoring data using the label_values query.

The query I'm using in Grafana is:

label_values(up, instance)

Unfortunately, Prometheus tells me that it is not aware of label_values:

Error executing query: parse error at char 13: unknown function with name "label_values"

I am using Prometheus 2.0.0 and Grafana 5.

What am I doing wrong?

like image 623
Tim Hartnack Avatar asked Mar 19 '18 14:03

Tim Hartnack


People also ask

What is label_ values in Grafana?

To create a variable in Grafana that contains all values of a specific label in a specific metric you can use label_values(metric, label) .

How do I use variables in Grafana query?

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 .

What are template variables in Grafana?

Template variables enable users to create dashboards that change dynamically based on user input. Since variables have been around in Grafana for a long time, many users expect them to be supported for any data sources they install.


1 Answers

label_values() is only a valid function within templating. You can use it to populate a template dropdown with e.g. a list of available instances or available metrics but you can't use it within a dashboard or when querying Prometheus directly.

like image 103
Oliver Avatar answered Sep 22 '22 02:09

Oliver