-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[pkg/ottl] Normalize replace_all_patterns function behavior #32896
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
You've come upon something OTTL doesn't do well: conditions on specific items in a dynamic list. Ultimately the way we wish we could handle this situation is with something like:
which we cannot express yet. I think #29289 would give us the solution. Your proposed solution would also work, but I'd rather solve the underlying problem which is that we cannot express how to access a map's key(s) in a condition. |
Side note, that is a very clever work around, one that I would consider a bug. I think we should patch that once we have a real solution for the kind of transformation you need. In my opinion the expected outcome of using |
@rnishtala-sumo curious on your thoughts. |
One thing about the issue reported and maybe this isn't obvious from the docs, is that at present it makes sense to use the optional function with matched group/s in the replacement string. For example:
The above hashes a substring from the original. It then makes sense that one would want to apply the function on the replacement string.
I agree, the function is applied to the key, but seems to replace the value with the updated key which is an issue. |
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
An alternative workaround to the one posted is to use the
|
This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
Component(s)
pkg/ottl
Is your feature request related to a problem? Please describe.
I'm implementing log sanitizing processor based on transformprocessor
One of goals - replace value in all 'token' fields with 'redacted' string.
First obvious solution is to use
replace_all_patterns(attributes, "key", "*.token.*", "redacted")
- but it will just rename the matched keysIf we look into function source, we will found that this behavior is changing if we use converting function in there :
replace_all_patterns(attributes, "key", "*.token.*", "redacted", SHA1)
- Now, the keys are left as is, but value is changed, with one note - the value isn't a sha1 hash of original value, but a hash of 'redacted' string that doesn't make sense.Describe the solution you'd like
Split it into two functions 'replace_all_keys' and 'replace_all_values', let them accept also 'key' and 'value' mode and apply them to only keys or only values. E.g:
This approach will allow to use any converting functions without affecting the behavior
Describe alternatives you've considered
My final solution is to apply SHA1 function with replacement format and the replace it one more time with 'redacted' string because it doesn't make sense to store a hashsum of replacement string.
Additional context
No response
The text was updated successfully, but these errors were encountered: