Case insensitive regex when using relabeling or metric_relabeling

2,619 views
Skip to first unread message

sujit....@gmail.com

unread,
Jun 27, 2017, 2:57:37 AM6/27/17
to Prometheus Users
Hi,

Is there any way to specify the ignore-case flag when defining the regex used in relabeling_config or metric_relabeling_config?

My scenario is that I am receiving the same value for a Consul tag (but with different letter case) from two different agents. I am extracting and adding the Consul tag as a label to the scraped metrics. As I try to match the label name inside the consul tag, the case sensitive regex skips part of the metrics. Currently, I have solved this using two separate set of relabel_configs (once for each case). 

However, I wanted to check if there is a more elegant/simpler way to handle case-insensitive label matching.

Thanks,
Sujit.

Brian Brazil

unread,
Jun 27, 2017, 3:13:22 AM6/27/17
to sujit....@gmail.com, Prometheus Users
On 27 June 2017 at 07:57, <sujit....@gmail.com> wrote:
Hi,

Is there any way to specify the ignore-case flag when defining the regex used in relabeling_config or metric_relabeling_config?

That's not supported.
 

My scenario is that I am receiving the same value for a Consul tag (but with different letter case) from two different agents. I am extracting and adding the Consul tag as a label to the scraped metrics. As I try to match the label name inside the consul tag, the case sensitive regex skips part of the metrics. Currently, I have solved this using two separate set of relabel_configs (once for each case). 

However, I wanted to check if there is a more elegant/simpler way to handle case-insensitive label matching.

The general answer would be to get your source data consistent. Different case is likely to cause fun throughout your systems.

--

Ben Kochie

unread,
Jun 27, 2017, 3:25:10 AM6/27/17
to sujit....@gmail.com, Prometheus Users
The regexp matching in Prometheus is based on RE2[0]

I think you can set flags within a match by using (?i(matchstring))


--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-users+unsubscribe@googlegroups.com.
To post to this group, send email to prometheus-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/179c33d0-0ee9-4994-a6d4-7691e74a82f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ben Kochie

unread,
Jun 27, 2017, 3:31:20 AM6/27/17
to sujit....@gmail.com, Prometheus Users
Sorry, that syntax was wrong.  It should be

(?i:(Match))

Sujit Vasudev

unread,
Jun 28, 2017, 4:20:01 PM6/28/17
to Ben Kochie, Prometheus Users
Thanks Ben! 

On Tue, Jun 27, 2017 at 2:31 AM Ben Kochie <sup...@gmail.com> wrote:
Sorry, that syntax was wrong.  It should be

(?i:(Match))
On Tue, Jun 27, 2017 at 9:25 AM, Ben Kochie <sup...@gmail.com> wrote:
The regexp matching in Prometheus is based on RE2[0]

I think you can set flags within a match by using (?i(matchstring))

On Tue, Jun 27, 2017 at 8:57 AM, <sujit....@gmail.com> wrote:
Hi,

Is there any way to specify the ignore-case flag when defining the regex used in relabeling_config or metric_relabeling_config?

My scenario is that I am receiving the same value for a Consul tag (but with different letter case) from two different agents. I am extracting and adding the Consul tag as a label to the scraped metrics. As I try to match the label name inside the consul tag, the case sensitive regex skips part of the metrics. Currently, I have solved this using two separate set of relabel_configs (once for each case). 

However, I wanted to check if there is a more elegant/simpler way to handle case-insensitive label matching.

Thanks,
Sujit.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To post to this group, send email to promethe...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages