opentelemetry-collector-contrib icon indicating copy to clipboard operation
opentelemetry-collector-contrib copied to clipboard

[attributeprocessor] Support filtering on metric attributes

Open ajsaclayan opened this issue 2 years ago • 1 comments

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

It would be nice to modify attributes on metrics based on a set of attribute values. This is already supported for spans and logs, but it is not supported for metrics. I think this was excluded when metrics had labels. More here https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/attributesprocessor#includeexclude-filtering

Describe the solution you'd like

With this configuration, I would expect all metrics with attribute some.key = some.value to have an attribute foo = true added.

 attributes/add-attr-based-on-filter:
    actions:
      - key: foo
        value: true
        action: insert
    include:
      match_type: strict
      attributes:
        - key: some.key
          value: some.value

Describe alternatives you've considered

I've considered using https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/metricstransformprocessor, but it only supports adding labels that are of type string.

Additional context

No response

ajsaclayan avatar Sep 20 '22 19:09 ajsaclayan

This is related but was never merged. https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/8395

ajsaclayan avatar Sep 20 '22 19:09 ajsaclayan

Pinging code owners: @boostchicken. See Adding Labels via Comments if you do not have permissions to add labels yourself.

github-actions[bot] avatar Sep 26 '22 19:09 github-actions[bot]

This is a part of a bigger issue where we have attribute processor config interface and behavior completely misaligned at least for metrics. Besides unimplemented support of attributes config field, the code supports expr filtering but it's not exposed in the config. I would like to make sure that configuration interface in attributes processor is reused with other components where the filtering is involved the same way as it's done for the code. This probably deserves another issue. Hopefully it'll result in more reusable code that is easier to read.

Looking for volunteers to work on this. This deserves another issue I believe.

@ajsaclayan please let us know if you're interested in this.

dmitryax avatar Nov 08 '22 21:11 dmitryax

@ajsaclayan @dmitryax the transform processor can handle this situation exactly:

transform:
  metric_statements:
    - context: datapoint
      statements:
        - 'set(attributes["foo"], true) where attributes["some.key"] == "some.value"'

TylerHelmuth avatar Nov 22 '22 16:11 TylerHelmuth

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

  • processor/attributes: @boostchicken

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

github-actions[bot] avatar Jan 23 '23 03:01 github-actions[bot]

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

  • processor/attributes: @boostchicken

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

github-actions[bot] avatar Mar 27 '23 03:03 github-actions[bot]

This issue has been closed as inactive because it has been stale for 120 days with no activity.

github-actions[bot] avatar May 26 '23 21:05 github-actions[bot]