opentelemetry-collector-contrib
opentelemetry-collector-contrib copied to clipboard
[attributeprocessor] Support filtering on metric attributes
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
This is related but was never merged. https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/8395
Pinging code owners: @boostchicken. See Adding Labels via Comments if you do not have permissions to add labels yourself.
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.
@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"'
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.
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.
This issue has been closed as inactive because it has been stale for 120 days with no activity.