Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to support replacing label values like regexp.ReplaceAllString #3997

Closed
Wing924 opened this Issue Mar 22, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@Wing924
Copy link

Wing924 commented Mar 22, 2018

have a metrics like resp_time_sum{vip="www_example_com"}.
I want to replace _ with . in vip label: resp_time_sum{vip="www.example.com"}

Currently, label_replace function can't do this because we can't know how many _ the value contains.
I asked this question in prometheus-users, but the suggest rename label in exporters.

Because we can't always change the exporters, I think add a new function label_gsub may be useful.

# dst_label = regex.ReplaceAllString(src_label, replacement)
label_gsub(v instant-vector, dst_label string, replacement string, src_label string, regex string)

gsub come from ruby's gsub

@Wing924 Wing924 changed the title [feature request] add function to support replacing label values like regexp.ReplaceAllString Add function to support replacing label values like regexp.ReplaceAllString Mar 22, 2018

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Mar 22, 2018

This sort of thing is best fixed in your source data. Regexes in PromQL are anchored, which are not compatible with global replacements.

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 22, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 22, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.