-
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
ottlfunc regex doesn't support double quotes #33534
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
The code owners for The following works for me:
|
|
Doing so, the Collector fails with error:
|
You'll need to escape I suggest testing that your regex is well formatted and then adding it to your config. |
Hi @TylerHelmuth , This one is correct, so it has nothing to do with the We are using this image and it does the parsing, as far as i can see: otel/opentelemetry-collector-contrib:0.101.0 |
I got mixed up on the number of parameters. The second parameter is a regex string. The third parameter is the replacement string, not regex, so you're right that nothing needs escaping. OTTL requires string literals to be in double quoates ( |
It works, thanks @TylerHelmuth! Not sure how I missed this during trial and error. |
Component(s)
pkg/ottl
Describe the issue you're reporting
Using the replace_pattern ottl func, I am nog able to use a double quote within the regex param. Which i require to transform within my JSON body
I would like to use something like this:
- replace_pattern(attributes["Body"], (?U)name\":\"(.*)\", name\":\"**********\",)
But it gives me the error:
Error: invalid configuration: processors::transform/avg: unable to parse OTTL statement "replace_pattern(attributes[\"Body\"], (?U)name\\\":\\\"(.*)\\\", name\\\":\\\"**********\\\",)": statement has invalid syntax: 1:38: invalid input text "?U)name\\\":\\\"(.*)..." 2024/06/13 05:45:43 collector server run finished with error: invalid configuration: processors::transform/avg: unable to parse OTTL statement "replace_pattern(attributes[\"Body\"], (?U)name\\\":\\\"(.*)\\\", name\\\":\\\"**********\\\",)": statement has invalid syntax: 1:38: invalid input text "?U)name\\\":\\\"(.*)..."
The text was updated successfully, but these errors were encountered: