open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
3.05k stars 2.35k forks source link

keep_matching_keys function not working with metric context #35956

Closed Shindek77 closed 1 week ago

Shindek77 commented 1 week ago

Component(s)

No response

Describe the issue you're reporting

Hello Community, is keep_matching_keys ottl function doest not work for metric context as i am using it but it is not working properly. Gives error on otel as processors::transform/test: unable to parse OTTL statement "keep_matching_keys(attributes,"^(url|http|service|cloud|event).")": undefined function "keep_matching_keys" . Please help me on this

transform/test:
  metric_statements:
  - context: metric
    statements:
    - keep_matching_keys(attributes, "^(url|http|service|cloud|event).")
    - keep_matching_keys(resource.attributes, "^(url|http|service|cloud|event).*").
github-actions[bot] commented 1 week ago

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.

github-actions[bot] commented 1 week ago

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

evan-bradley commented 1 week ago

Hi @Shindek77, which version of the Collector are you using?

TylerHelmuth commented 1 week ago

context: metric uses ottlmetric which doesnt provide access to attributes since metrics do not have attributes, their datapoints do.

Likely you want to use context: datapoint.