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

feat: support transformer replaceRegex #632

Merged
merged 1 commit into from
Sep 13, 2023

Conversation

dongjiang1989
Copy link
Contributor

@dongjiang1989 dongjiang1989 commented Sep 7, 2023

Proposed Changes:

Add transformer replaceRegex action.
like: https://grafana.com/docs/loki/latest/clients/promtail/stages/replace/

Which issue(s) this PR fixes:

Fixes #630

Additional documentation:

interceptors:
  - type: transformer
    actions:
      - action: replaceRegex(body)  
        expression: <string> // The RE2 regular expression. Each named capture group will be replaced with the value given in `replace`
        replace: <string> //
      ...

expression needs to be a Go RE2 regex string.
replace is a replace value.

use:

    actions:
      - action: replaceRegex(body)  // SSN
        expression: '([0-9]{3}-[0-9]{2}-[0-9]{4})'
        replace: '*SSN*'
      - action: replaceRegex(body)  // IP4
        expression: '(\d{1,3}[.]\d{1,3}[.]\d{1,3}[.]\d{1,3})'
        replace: '*IP4*' 
      - action: replaceRegex(body)  // email
        expression: '([\w\.=-]+@[\w\.-]+\.[\w]{2,64})'
        replace: '*email*' 

Signed-off-by: dongjiang1989 <[email protected]>
@dongjiang1989
Copy link
Contributor Author

/cc @ethfoo PTAL

@ethfoo ethfoo merged commit ae4a725 into loggie-io:main Sep 13, 2023
2 checks passed
@dongjiang1989 dongjiang1989 deleted the replaceRe2 branch November 21, 2023 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support transformer replace action
2 participants