prometheusmetricspromqlprometheus-operator

What is difference between = and =~ operator in prometheus?


What is the meaning of =~ operator in prometheus metrics?

What is the exact difference between = and =~ operator?

For example,

process_cpu_seconds_total{instance="test"} 
process_cpu_seconds_total{instance=~"test"}

The results are different.


Solution

  • =~: Select labels that regex-match the provided string.

    For example, this selects all http_requests_total time series for staging, testing, and development environments and HTTP methods other than GET.

    http_requests_total{environment=~"staging|testing|development",method!="GET"}
    

    Taken from the Prometheus.io docs.