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 Tracing on v0.109.0 #36409

Closed
baikunthasahoo opened this issue Nov 18, 2024 · 6 comments
Closed

Filtering Tracing on v0.109.0 #36409

baikunthasahoo opened this issue Nov 18, 2024 · 6 comments
Labels
processor/filter Filter processor

Comments

@baikunthasahoo
Copy link

Component(s)

processor/filter

Describe the issue you're reporting

Hi Team,

I am trying to exclude spans in the OpenTelemetry Collector using the filterprocessor. Specifically, I need to exclude spans where the next.route attribute matches the following values:

/api/healthz
/[locale]/api/healthz (where [locale] is dynamic, e.g., /en, /fr, etc.)
Despite configuring the filterprocessor with a regular expression, I am still seeing these spans in the traces. Below are the steps, configurations, and behaviors observed.

filter/exclude-health-api-traces:
spans:
exclude:
match_type: regexp
attributes:
- key: "http.target"
value: ".\/api\/healthz."

          - key: "http.target"
            value: ".*\\/api\\/healthz.*"

          - key: "http.url"
            value: "http:\\/\\/\\d+\\.\\d+\\.\\d+\\.\\d+:3000\\/(view|file|cloud|api)\\/api\\/healthz"

          - key: "http.user_agent"
            value: ".*kube-probe\\/1\\..*"

          - key: "next.route"
            value: "(\\/[^\\/]+)?\\/api\\/healthz"

  filter/spans:
    spans:
      exclude:
        match_type: regexp
        span_names:
          - ".*\\/api\\/healthz.*"
          - ".*\\/api\\/health\\/.*"

I need your support on above query

Note: I have deployed my application in Kubernetes and used health probes for every 10sc. my application send data to collector as daemonset from otel collector i am exporting my traces.

@baikunthasahoo baikunthasahoo added the needs triage New item requiring triage label Nov 18, 2024
@github-actions github-actions bot added the processor/filter Filter processor label Nov 18, 2024
Copy link
Contributor

Pinging code owners:

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

@bacherfl
Copy link
Contributor

Hi @baikunthasahoo!

Can you check whether something like the following config may help you to achieve this? This makes use of the IsMatch OTTL function:

receivers:
  otlp:
    protocols:
      grpc:
        endpoint: 0.0.0.0:4317
processors:
  filter:
    traces:
      span:
        - 'IsMatch(attributes["http.target"], ".*\\/api\\/healthz.*")'


exporters:
  debug:
    verbosity: detailed

service:

  pipelines:
    traces:
      receivers: [otlp]
      processors: [filter]
      exporters: [debug]

With this config, the following span was filtered as expected:

telemetrygen traces --otlp-insecure --traces 1 --status-code Ok --span-duration 1s --telemetry-attributes http.target=\"/api/healthz\"

@baikunthasahoo
Copy link
Author

@bacherfl

Thanks for your quick support. Here i want suppress the /api/healthz noise. Does above example will suppress the ./api/healthz. ?

@bacherfl
Copy link
Contributor

Yes, this configuration will filter out all spans with the http.target attribute set to /api/healthz

@baikunthasahoo
Copy link
Author

Thank so much !! @bacherfl

Its working for me.

@bacherfl bacherfl removed the needs triage New item requiring triage label Nov 18, 2024
@bacherfl
Copy link
Contributor

awesome, thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
processor/filter Filter processor
Projects
None yet
Development

No branches or pull requests

2 participants