prometheus icon indicating copy to clipboard operation
prometheus copied to clipboard

docs (label_replace): illustrate use of named capturing group

Open gberche-orange opened this issue 2 years ago • 2 comments

Illustrate use of named capturing group syntax available from https://github.com/google/re2/wiki/Syntax and their usage in the replacement field

Signed-off-by: Guillaume Berche [email protected]

gberche-orange avatar Oct 03 '22 16:10 gberche-orange

Thank you for your pull request.

Our documentation is not meant as a replacement for re2 syntax and I feel like dropping such an example would be more confusing for users. In addition, for the very vast majority of usecases, named groups are not needed since label replace deals with simple replacements.

roidelapluie avatar Oct 13 '22 08:10 roidelapluie

thanks for your review. The proposed changed does not aim at duplicating RE2 syntax, but to rather confirm that named groups can be accessed by $name. I had to guess it as only indexed group reference such as $1 were documented.

I've added a commit to remove the example and only keep the description refinement.

gberche-orange avatar Oct 13 '22 08:10 gberche-orange

We have discussed this during our bug scrub. We found out that it is confusing that this pull request does not explain how to do capturing groups. Maybe the sentence should be moved to a dedicated example showing the usage of named capturing groups, WDYT?

roidelapluie avatar Jul 11 '23 11:07 roidelapluie

We have discussed this during our bug scrub. We found out that it is confusing that this pull request does not explain how to do capturing groups. Maybe the sentence should be moved to a dedicated example showing the usage of named capturing groups, WDYT?

Thanks @roidelapluie the original change at https://github.com/prometheus/prometheus/pull/11404/commits/ea40c15fe9d69273281bda41ab3e300087156ec8 explained usage of named group by comparing it with syntax without named group.

Is it what what was expected during the bug scrub ?

gberche-orange avatar Jul 11 '23 16:07 gberche-orange

Can we maybe split the named capture group into a second exemple with the explanation?

roidelapluie avatar Jul 11 '23 16:07 roidelapluie

Can you please review https://github.com/prometheus/prometheus/pull/11404/commits/60b380da70213975bfd343be64f5b89b03e2c944 ?

Feel free to squash / edit as needed if this can be faster or more productive.

gberche-orange avatar Jul 12 '23 07:07 gberche-orange

Thanks!

roidelapluie avatar Jul 28 '23 11:07 roidelapluie