Skip to main content

Attributes Processor

Status Available in: core, contrib, k8s Maintainers: @boostchicken Source: opentelemetry-collector-contrib

Supported Telemetry

Logs Metrics Traces

Overview

The attributes processor modifies attributes of a span, log, or metric. Please refer to config.go for the config spec. This processor also supports the ability to filter and match input data to determine if they should be included or excluded for specified actions. It takes a list of actions which are performed in order specified in the config. The supported actions are:
  • insert: Inserts a new attribute in input data where the key does not already exist.
  • update: Updates an attribute in input data where the key does exist.
  • upsert: Performs insert or update. Inserts a new attribute in input data where the key does not already exist and updates an attribute in input data where the key does exist.
  • delete: Deletes an attribute from the input data.
  • hash: Hashes (SHA1) an existing attribute value.
  • extract: Extracts values using a regular expression rule from the input key to target keys specified in the rule. If a target key already exists, it will be overridden. Note: It behaves similar to the Span Processor to_attributes setting with the existing attribute as the source.
  • convert: Converts an existing attribute to a specified type.
For the actions insert, update and upsert,
  • key is required
  • one of value, from_attribute, from_context, or default_value is required
  • action is required.
For the delete action,
  • key and/or pattern is required
  • action: delete is required.
For the hash action,
  • key and/or pattern is required
  • action: hash is required.
For the extract action,
  • key is required
  • pattern is required.
For the convert action,
  • key is required
  • action: convert is required.
  • converted_type is required and must be one of int, double or string

Default Values

The default_value field can be used to specify a fallback value when the primary value source (e.g., attribute, or context value) is not available. This is useful for:
  • Providing sensible defaults when attributes don’t exist
  • Ensuring the pipeline doesn’t fail due to missing configuration
The list of actions can be composed to create rich scenarios, such as back filling attribute, copying values to a new key, redacting sensitive information. The following is a sample configuration.
Refer to config.yaml for detailed examples on using the processor.

Attributes Processor for Metrics vs. Metric Transform Processor

Regarding metric support, these two processors have overlapping functionality. They can both do simple modifications of metric attribute key-value pairs. As a general rule the attributes processor has more attribute related functionality, while the metrics transform processor can do much more data manipulation. The attributes processor is preferred when the only needed functionality is overlapping, as it natively uses the official OpenTelemetry data model. However, if the metric transform processor is already in use or its extra functionality is necessary, there’s no need to migrate away from it. Shared functionality
  • Add attributes
  • Update values of attributes
Attribute processor specific functionality
  • delete
  • hash
  • extract
Metric transform processor specific functionality
  • Rename metrics
  • Delete data points
  • Toggle data type
  • Scale value
  • Aggregate across label sets
  • Aggregate across label values

Include/Exclude Filtering

The attribute processor exposes an option to provide a set of properties of a span, log or metric record to match against to determine if the input data should be included or excluded from the processor. To configure this option, under include and/or exclude at least match_type and one of the following is required:
  • For spans, one of services, span_names, span_kinds, attributes, resources or libraries must be specified with a non-empty value for a valid configuration. The log_bodies, log_severity_texts, log_severity_number and metric_names fields are invalid.
  • For logs, one of log_bodies, log_severity_texts, log_severity_number, attributes, resources or libraries must be specified with a non-empty value for a valid configuration. The span_names, span_kinds, metric_names and services fields are invalid.
  • For metrics, one of metric_names or resources must be specified with a valid non-empty value for a valid configuration. The span_names, span_kinds, log_bodies, log_severity_texts, log_severity_number, services, attributes and libraries fields are invalid.
Note: If both include and exclude are specified, the include properties are checked before the exclude properties.

Match Configuration

Some match_type values have additional configuration options that can be specified. The match_type value is the name of the configuration section. These sections are optional.

Warnings

In general, the Attributes processor is a very safe processor to use. Care only needs to be taken when modifying data point attributes:
  • Identity Conflict: Reducing/changing existing data point attributes has the potential to create an identity conflict since the Attributes processor does not perform any re-aggregation of the data points. Adding new attributes to data points is safe.

Configuration

Example Configuration


Last generated: 2026-08-24