Query label_values not found in Prometheus

Tim Hartnack picture Tim Hartnack · Mar 19, 2018 · Viewed 17.1k times · Source

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?

Answer

Oliver picture Oliver · Mar 19, 2018

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.