Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prometheus query and case sensitivity

I have one query where I am trying to join two metrics on a label. K_Status_Value == 5 and ON(macAddr) state_details{live="True"}

The label macAddr is present in both the metrics. The value of the label appears in 'K_Status_Value' sometimes in upper case (78:32:5A:29:2F:0D) and sometimes in lower case (78:72:5d:39:2f:0a) but always appears in upper case for 'state_details'. Is there any way I can make the label macAddr value case-insensitive in the query so that I don't miss out on the occurrences where the cases don't match?

like image 358
Arnav Bose Avatar asked Nov 15 '18 03:11

Arnav Bose


People also ask

What is querying in Prometheus?

Querying Prometheus. Prometheus provides a functional query language called PromQL (Prometheus Query Language) that lets the user select and aggregate time series data in real time. The result of an expression can either be shown as a graph, viewed as tabular data in Prometheus's expression browser, or consumed by external systems via the HTTP API.

How to expose data from your application to Prometheus?

The Data can be exposed to Prometheus through client libraries and exporters. Client libraries can help you create & expose metrics from your application code, and exporters are being used when you can’t change the application’s source code. Prometheus uses various exporters to monitor third-party applications like an HTTP server or a database.

How to configure alerting rules in Prometheus?

The alerting rules can be configured in Prometheus, but a separate component called Alertmanager is needed to manage the alerts. For visualization, You can use PromQL to query the metrics and generate graphs in the Prometheus web UI.

What is Prometheus monitoring?

Prometheus is an open source metrics-based monitoring system. It has a multi-dimensional data model and has a strong query language to query that data model. This blog post will discuss monitoring in general and Prometheus from a beginner’s point of view.


1 Answers

I can think of two options

Using regex "i" match modifier:

To quote Ben Kochie on Prometheus user mailing list:

The regexp matching in Prometheus is based on RE2 I think you can set flags within a match by using (?i(matchstring))

It works indeed: this metric up{instance="localhost:9090",job="prometheus"} is matched by this expression :

up{job=~"(?i:(ProMeTHeUs))"}

This hint won't help in the case described above. It won't help either to join on (xx) or group_left.

Using a recording rule:

I was initialy hoping to use a recording rule to lower case at ingestion time (in prometheus.yml). However this features is not implemented at this time (issue 1548)

like image 107
Franklin Piat Avatar answered Sep 20 '22 11:09

Franklin Piat