-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[prometheusremotewriteexporter] Allow to disable sanitize metric labels #8270
Conversation
Is this a bug? A feature request? Is there an issue tracking this? |
@@ -107,7 +109,7 @@ func (prwe *prwExporter) PushMetrics(ctx context.Context, md pdata.Metrics) erro | |||
case <-prwe.closeChan: | |||
return errors.New("shutdown has been called") | |||
default: | |||
tsMap, err := prometheusremotewrite.FromMetrics(md, prometheusremotewrite.Settings{Namespace: prwe.namespace, ExternalLabels: prwe.externalLabels}) | |||
tsMap, err := prometheusremotewrite.FromMetrics(md, prometheusremotewrite.Settings{Namespace: prwe.namespace, ExternalLabels: prwe.externalLabels, SanitizeLabel: prwe.sanitizeLabel}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be done without changing the exported interface of the PRW translator package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see much options, one is to introduce a feature flag in the translator package, but I was thinking to reuse the same feature flag as basically it's about the same thing as #7112 , thus an additional fields in prometheusremotewrite.Settings
will be introduced to follow previous behavior by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is that feature gates are intended to be temporary and removed eventually. Changes to the public API of a package are not reversible (assuming a world where we're v1.x, which we need to start planning for) and thus should be avoided in conjunction with feature gates. It is hypothesized that the sanitization of labels starting with _
(but not __
) is unnecessary, so perhaps we should focus on finding a way to gain confidence in that hypothesis and eliminating the need for this feature gate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand the concern of changing the public API in translator, but it's still the same behavior by default, with regards to gain confidence in the hypothesis, I am not sure how we can move forward on that. could you please elaborate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @Aneurysm9 any thoughts on how we can move forward on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we should probably eliminate it altogether rather than further propagating it. Changing the public API of this module does not seem like the correct thing to do.
I'm not sure I'm comfortable making this decision by myself. @dashpole @bogdandrutu @jpkrohling @codeboten @gouthamve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that sounds like this will be a breaking change which is going to remove the key
prefix.
If not to change the public API, would it work that introduce a new method similar to FromMetrics
which does not sanitize label(no key
prefix)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the public API of this module does not seem like the correct thing to do.
I share the same opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also agree we should not change the public API. We should either make the change outright, or use a feature-gate to slowly make the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a feature gate for this.
@jpkrohling it's a feature request. I searched issues and didn't see one for this. |
Signed-off-by: Peter Deng <[email protected]> # Conflicts: # CHANGELOG.md # pkg/translator/prometheusremotewrite/helper.go # pkg/translator/prometheusremotewrite/helper_test.go # pkg/translator/prometheusremotewrite/testutils_test.go
Signed-off-by: Peter Deng <[email protected]> # Conflicts: # CHANGELOG.md # pkg/translator/prometheusremotewrite/helper.go
# Conflicts: # CHANGELOG.md
Once @Aneurysm9 approves, I'll merge this. |
# Conflicts: # CHANGELOG.md # pkg/translator/prometheusremotewrite/helper.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this misses some calls to sanitize elsewhere in helper.go. It seems like it would be simpler to just check the feature gate from within sanitize()
:
- if s[0] == '_' {
+ if !featuregate.IsEnabled(dropSanitizationGate.ID) && s[0] == '_' {
s = keyStr + s
}
good point. updated. |
@dashpole @Aneurysm9 @jpkrohling could you please review again? |
Co-authored-by: David Ashpole <[email protected]>
Description:
This PR does the similar thing as #7112 , while the previous PR covers external labels defined in config, this PR follow the same config and allows to disable sanitize labels from scrapped metrics.
Link to tracking Issue:
Testing:
Documentation: