I want to select all metrics that don't have label "container". Is there any possibility to do that with prometheus query?
If you want to add a label unconditionally to every metric returned from a specific scrape job, then just add the label in the service discovery (e.g. "file_sd_configs" or "static_configs"). Different labels can be applied for different groups of targets, e.g.
PromQL does not support the * wildcard that Lucene queries use. Instead, use "~" before the value you want to search, and ". +" at the end of it.
PromQL, short for Prometheus Querying Language, is the main way to query metrics within Prometheus. You can display an expression's return either as a graph or export it using the HTTP API. PromQL uses three data types: scalars, range vectors, and instant vectors. It also uses strings, but only as literals.
up{job="<job-name>", instance="<instance-id>"} : 1 if the instance is healthy, i.e. reachable, or 0 if the scrape failed. i.e. it is a per scraper / exporter metric which means whether the exporter was available / reachable or not.
Try this:
{__name__=~".+",container=""}
There needs to be at least one non-empty matcher (hence the +
in the __name__
regular expression, *
wouldn't cut it). And the way you query for a missing label is by checking for equality with the empty string.
In recent versions of Prometheus it's enought to query for something like this:
node_load1{not_existent_label=""}
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