Re: [prometheus-users] Wildcard in PromQL "5.+" vs "5\\d{2}"

2023-10-08 Thread Julius Volz
Hi Jason,

Prometheus uses the RE2 regular expression dialect, you can find the
documentation about that here: https://github.com/google/re2/wiki/Syntax

The double backslash ("\\") is just to escape the one backslash in the
Prometheus string. So the actual regex is just "5\\d{2}". You can remove
the escaping by using backticks as quotes, which do not interpret escape
sequences: `5\d{2}`

Kind regards,
Julius

On Tue, Oct 3, 2023 at 12:03 PM 'Jason' via Prometheus Users <
prometheus-users@googlegroups.com> wrote:

> On 03.10.2023 10:55, Stuart Clark wrote:
> > In reality both will do the same thing, although the second is
> > technically more correct.
> >
> > The first regular expression is matching "5" followed by 1 or more other
> > characters, while the second is matching "5" followed by exactly 2
> > numbers. So the first one would also match "50" or "5frogs" which aren't
> > valid status codes, but in reality your application would have to be
> > having serious problems to be setting those values anyway.
>
> Thanks Stuart
>
> Is there any docs about this type of regex? I didn't found "\\d" in
> official docs.
>
> How is this regex called?
>
> cheers
> Jason
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-users/988b8358-d588-4120-8768-d8c7f29fe8f5%407748229.xyz
> .
>


-- 
Julius Volz
PromLabs - promlabs.com

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/CAObpH5zXYjub7zdx%2BrxkGDqf9AajatS-jEzjkGqJ-9Wd7cQPOA%40mail.gmail.com.


Re: [prometheus-users] Wildcard in PromQL "5.+" vs "5\\d{2}"

2023-10-03 Thread 'Jason' via Prometheus Users

On 03.10.2023 10:55, Stuart Clark wrote:
In reality both will do the same thing, although the second is 
technically more correct.


The first regular expression is matching "5" followed by 1 or more other 
characters, while the second is matching "5" followed by exactly 2 
numbers. So the first one would also match "50" or "5frogs" which aren't 
valid status codes, but in reality your application would have to be 
having serious problems to be setting those values anyway.


Thanks Stuart

Is there any docs about this type of regex? I didn't found "\\d" in 
official docs.


How is this regex called?

cheers
Jason

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/988b8358-d588-4120-8768-d8c7f29fe8f5%407748229.xyz.


OpenPGP_0x0D0C34B5DF58FE9D.asc
Description: OpenPGP public key


OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: [prometheus-users] Wildcard in PromQL "5.+" vs "5\\d{2}"

2023-10-03 Thread Stuart Clark

On 2023-10-03 09:09, 'Jason' via Prometheus Users wrote:

Hi

I will write my query like this (with * wildcad)

sum(http_requests_total{status_code=~"5.+"})

In internet I found this syntax \\d{2}

sum(http_requests_total{status_code=~"5\\d{2}"})

What is this? Where to find more info?
Why I should use the 2nd query and not the first?


In reality both will do the same thing, although the second is 
technically more correct.


The first regular expression is matching "5" followed by 1 or more other 
characters, while the second is matching "5" followed by exactly 2 
numbers. So the first one would also match "50" or "5frogs" which aren't 
valid status codes, but in reality your application would have to be 
having serious problems to be setting those values anyway.


--
Stuart Clark

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/1a56f89b81a2f5202b3613d12330b1c8%40Jahingo.com.


[prometheus-users] Wildcard in PromQL "5.+" vs "5\\d{2}"

2023-10-03 Thread 'Jason' via Prometheus Users

Hi

I will write my query like this (with * wildcad)

sum(http_requests_total{status_code=~"5.+"})

In internet I found this syntax \\d{2}

sum(http_requests_total{status_code=~"5\\d{2}"})

What is this? Where to find more info?
Why I should use the 2nd query and not the first?

cheers
Jason

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/7ed6fcb4-9b35-4d53-aa6c-ff4767af0c5e%407748229.xyz.


OpenPGP_0x0D0C34B5DF58FE9D.asc
Description: OpenPGP public key


OpenPGP_signature.asc
Description: OpenPGP digital signature