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

Replace pipeline stage #2033

Closed
cyriltovena opened this issue May 4, 2020 · 3 comments · Fixed by #2060 or #2432
Closed

Replace pipeline stage #2033

cyriltovena opened this issue May 4, 2020 · 3 comments · Fixed by #2060 or #2432
Labels
component/agent component/integrations good first issue These are great first issues. If you are looking for a place to start, start here! help wanted We would love help on these issues. Please come help us!

Comments

@cyriltovena
Copy link
Contributor

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

Currently it's difficult to replace password or unwanted data in a log line.
This is mainly because you have to matches everything else than what you want to replace in a regexp stage and use that in a template stage. Quite difficult to get right.

Describe the solution you'd like
I'm suggesting we add a new pipeline stages named replace that will replace matches from a regex with string.

replace:
  # The RE2 regular expression. Each capture group will be replaced.
  expression: <string>

  # Name from extracted data to parse. If empty, uses the log message.
  [source: <string>]
  
  # The string to replace matches with.
  [replacement: <string>]

Alternatively replacement could be a template like template stage for more complex scenario.

Additional context
Couple of request in slack for this.

/cc @slim-bean @owen-d @sandeepsukhani WDYT ?

@cyriltovena cyriltovena self-assigned this May 5, 2020
@cyriltovena cyriltovena added component/agent component/integrations good first issue These are great first issues. If you are looking for a place to start, start here! help wanted We would love help on these issues. Please come help us! labels May 5, 2020
@cyriltovena cyriltovena removed their assignment May 5, 2020
@adityacs
Copy link
Contributor

adityacs commented May 6, 2020

Can we make this substage to regex? Outside of regex stage it will be duplicate of template stage except for accepting expression. May be we can just call template process from the regex stage if above configuration is defined.

@cyriltovena
Copy link
Contributor Author

Could you show an example?

@adityacs
Copy link
Contributor

adityacs commented May 7, 2020

It would be same as the one you have shown above. Just that instead of defining one more stage we can use the existing regex stage with an extra check to see if there is replace field

Default regex stage.

Here all captured group will be set to extracted.

regex:
  expression: <string>

  [source: <string>]

regex stage with replace field.

Here we check if replace field is present. If yes, we replace all captured group value with the value given in replace field and then set to extracted.

regex:
  expression: <string>

  [source: <string>]

  [replace: <string>]

The check can be made here and we can call the template process() in this loop

extracted[name] = match[i]

template stage itself sets the extracted so we can ignore the above one from regex stage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/agent component/integrations good first issue These are great first issues. If you are looking for a place to start, start here! help wanted We would love help on these issues. Please come help us!
Projects
None yet
2 participants