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

Filtering doesn't work with JSONed logs after migrating to OTEL collector #3283

Closed
prysmakou-sa opened this issue Sep 19, 2023 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@prysmakou-sa
Copy link

After migrating to OTEL collector our JSONed logs aren't processed by filters.

Steps to reproduce:

Add a filter (eg to wipe out emails):

sumologic:
  metrics:
    enabled: false
  setup:
    force: true
  traces:
    enabled: false
  logs:
    priorityClassName: ${priorityClassName}
    statefulset:
      priorityClassName: ${statefulsetPriorityClassName}
    container:
      otelcol:
        extraProcessors:
          - transform/mask-email:
              log_statements:
                - context: log
                  statements:
                    - replace_pattern(body, "([a-zA-Z0-9_.+i\\-]+@)([a-zA-Z0-9\\-]+)(\\.[a-zA-Z0-9.]+)", "xxxxxx")

from your cluster run:
kubectl run -it logtest --image=node:18-alpine --restart=Never --rm -- node -e "console.error(JSON.stringify({level:'error', message:'test', data:{ email: '[email protected]' }}));"

Expected result: the email is filtered out from the logs in Sumologic.
The real result: the filter is ignored.

Run a similar command for the regular/string logs (to be sure it's not an issue with the filter syntax):

kubectl run -it logtest --image=node:18-alpine --restart=Never --rm -- node -e "console.error('email: [email protected]');"

Some more details about our environment:
EKS 1.25
helm chart 3.15.0

@prysmakou-sa prysmakou-sa added the bug Something isn't working label Sep 19, 2023
@swiatekm
Copy link

This is fixed by #3281 and will be present in the next release (3.16).

As a workaround, you can do the following:

- set(body, Concat([body], ""))
- replace_pattern(body, "([a-zA-Z0-9_.+i\\-]+@)([a-zA-Z0-9\\-]+)(\\.[a-zA-Z0-9.]+)", "xxxxxx")
- set(body, ParseJSON(body)) where IsMatch(body, "^{")

@prysmakou-sa
Copy link
Author

- set(body, ParseJSON(body)) where IsMatch(body, "^{")

I tested it in our environment and it works! Thank you @swiatekm-sumo !

@swiatekm
Copy link

#3281 was merged, so I'm going to close this issue for now. If the upcoming 3.16 release doesn't fix your issue @prysmakou-sa , please reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants