Search code examples
prometheuspromql

Prometheus regex match on different labels


I want to do a filter in prometheus based on all labels. Say if my labels in prometheus are instance, cpu, mode for the query node_cpu_seconds_total, i want to do an operation like,

input = ".*abc.*"

node_cpu_seconds_total{instance=~".*abc.*" or mode=~".*abc.*" or cpu=~".*abc.*"}

Basically i want my regex to be compared with all label values . Is there any solution to achieve this?


Solution

  • You cannot achieve this with vector selectors but you can use union operator OR to get the union of selections:

    node_cpu_seconds_total{instance=~".*abc.*"} or \
    node_cpu_seconds_total{mode=~".*abc.*"} or \
    node_cpu_seconds_total{cpu=~".*abc.*"}
    

    BUT there is no all label values selector - meaning you have to specify all labels.

    Note that this is rather an odd kind of request.