Skip to content

[pkg/ottl] Add support PCRE2 regex syntax #32167

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

Closed
aofodo opened this issue Apr 4, 2024 · 12 comments
Closed

[pkg/ottl] Add support PCRE2 regex syntax #32167

aofodo opened this issue Apr 4, 2024 · 12 comments
Labels
closed as inactive discussion needed Community discussion needed enhancement New feature or request pkg/ottl Stale

Comments

@aofodo
Copy link

aofodo commented Apr 4, 2024

Component(s)

processor/transform

Is your feature request related to a problem? Please describe.

I need to mask PANs (card numbers) in logs. Card numbers can be in different versions. With different dividers, different lengths. It is important that other data is not accidentally masked. To do this, I use a complex regular expression, including lookahead and other features of the PCRE2 syntax. Without the syntax capabilities of PCRE2, it is impossible to fully mask card numbers

Describe the solution you'd like

Add support PCRE2 syntax in processor/transform for replace_pattern and replace_all_patterns

Describe alternatives you've considered

No response

Additional context

No response

@aofodo aofodo added enhancement New feature or request needs triage New item requiring triage labels Apr 4, 2024
@github-actions github-actions bot added the processor/transform Transform processor label Apr 4, 2024
Copy link
Contributor

github-actions bot commented Apr 4, 2024

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@TylerHelmuth
Copy link
Member

TylerHelmuth commented Apr 5, 2024

@aofodo we use Go's built-in package for regex which I don't believe supports PCRE2 regexes by design. We'd need to find a suitable library to implement this feature request.

@TylerHelmuth TylerHelmuth added discussion needed Community discussion needed and removed needs triage New item requiring triage labels Apr 5, 2024
@amal-v
Copy link

amal-v commented Apr 11, 2024

We are trying to remove the . from the k8sattributes for k8s labels. For Eg k8s.pods.labels.service.version=1 to k8s.pods.labels.service_version=1. We require some advanced regex like PCRE2 to perform these operations.

@TylerHelmuth
Copy link
Member

@amal-v can you share the PCRE2 regex you'd like to use for your use case?

@rdeavila94
Copy link

Ditto this. I have a use case where a span attribute is a JSON string and I need to obfuscate the JSON values with the exception of some that correspond to a specific JSON key. Doesn't seem possible without a negative lookbehind.

for reference

transform:
  error_mode: ignore
  trace_statements:
    - context: span
      statements:
        - "replace_pattern(attributes[\"my-attribute\"], \"(?<!\\\"(key1|key2)\\\": )\\\"[^\\\"]+\\\"\", \"?\")"

There's probably a way to do this by transforming across multiple transformation stages but a single regex solution is much preferable.

@evan-bradley evan-bradley added pkg/ottl and removed processor/transform Transform processor labels Apr 15, 2024
Copy link
Contributor

Pinging code owners for pkg/ottl: @TylerHelmuth @kentquirk @bogdandrutu @evan-bradley. See Adding Labels via Comments if you do not have permissions to add labels yourself.

@evan-bradley evan-bradley changed the title [processor/transform] Add support PCRE2 regex syntax [pkg/ottl] Add support PCRE2 regex syntax Apr 15, 2024
@TylerHelmuth
Copy link
Member

Negative lookahead isn't supported by Go's regexp package, so we'd need another regular expression package that does.

@aofodo
Copy link
Author

aofodo commented Apr 16, 2024

I haven't had a chance to work with it, but this package go.arsenm.dev/pcre looks good. But it has limitations in target os and arch

@TylerHelmuth
Copy link
Member

TylerHelmuth commented Apr 16, 2024

But it has limitations in target os and arch

That will be a dealbreaker as OTTL needs to work in all the target architectures supported by https://github.com/open-telemetry/opentelemetry-collector-releases

Copy link
Contributor

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 @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

Copy link
Contributor

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 @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions github-actions bot added the Stale label Aug 19, 2024
Copy link
Contributor

This issue has been closed as inactive because it has been stale for 120 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed as inactive discussion needed Community discussion needed enhancement New feature or request pkg/ottl Stale
Projects
None yet
Development

No branches or pull requests

5 participants