Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAppending text to a subgroup #4704
Comments
This comment has been minimized.
This comment has been minimized.
|
Try It makes more sense to ask questions like this on the prometheus-users mailing list rather than in a GitHub issue. On the mailing list, more people are available to potentially respond to your question, and the whole community can benefit from the answers provided. |
brian-brazil
closed this
Oct 7, 2018
This comment has been minimized.
This comment has been minimized.
|
Thanks, for anyone searching this does resolve the problem I was having. |
lock
bot
locked and limited conversation to collaborators
Apr 10, 2019
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
lambertjosh commentedOct 7, 2018
It does not appear possible to append text directly to a subgroup, without introducing characters in between.
I have a metric that outputs the exact HTTP return codes, and I'd like to instead view these as their groups. (e.g. 2xx, 4xx, 5xx)
I can do this with some very ugly nested label_replace's:
sum(label_replace(label_replace(label_replace(label_replace(rate(nginx_ingress_controller_requests[2m]), "status_code", "5xx", "status", "5.*"), "status_code", "4xx", "status", "4.*"), "status_code", "3xx", "status", "3.*"), "status_code", "2xx", "status", "2.*")) by (status_code)But I would much prefer to use a regex subgroup to grab the group code, then append
xxonto it. For example:label_replace(rate(nginx_ingress_controller_requests[2m]), "status_code", "$1xx", "status", "(.)..")However this has the weird behavior of actually doing nothing. If you put a space or any symbol between
$1and the trailing text, it works, but it would be nice for there to be some method to do this cleanly.