Filter Data in the OpenTelemetry Collector
To filter data using the OpenTelemetry Collector:- Add the required
processorsto the OpenTelemetry Collector’s configuration file. The processors allow you to delete, edit or redact, or hash specific attributes. - Activate the processor functionality by modifying the appropriate
service | pipelines.
processors available for filtering sensitive data are:
attributes- to access individual attributes within a spanredaction- to mask or block the attributes’ values for securitytransform- to transform the values within the spans
Attributes Processor
Theattributes processor is generally used instead of the other two processors (redaction and transform) to access individual attributes within a span.
Use the attributes processor to:
- Add, modify, or remove attributes from your telemetry data, such as specific keys like credit card information, passwords, and other sensitive values
- Filter and match input data to determine if they should be included or excluded for specified actions
Attributes Example
In this example, the configuration redacts the value in thecc_number attribute, deletes the account_password attribute, and hashes the account_email attribute.
Redaction Processor
Theredaction processor is generally used instead of the other two processors (attributes and transform) to mask the attributes’ values for security.
Use the redaction processor to:
- Remove or mask sensitive information from your telemetry data. This is useful for compliance or security purposes to ensure sensitive information is not leaked
- Delete span attributes that do not match a list of allowed span attributes
- Mask span attribute values that match a blocked value list. Span attributes not on the allowed list are removed before value checks are done
Redaction Examples
Remove
In this example, use theredaction processor to remove all attributes except description, group, and id:
Block
In this example, use regex to block credit card numbers for Visa, Amex, and Mastercard. Additionally, use regex to block IP addresses.Transform Processor
Thetransform processor is generally used instead of the other two processors (attributes and redaction) to transform the values within the spans.
Use the transform processor to transform attributes by modifying or adding new attributes to the data before it is exported.
The transform processor enables specific requirements, such as renaming attributes, adding or removing tags, or modifying the data structure.
OTel Transformation Language (OTTL)
OTel Transformation Language (OTTL) is a scripting language used in thetransform processor of the OpenTelemetry Collector to manipulate and transform telemetry data.
Using OTTL scripts, you can process telemetry data in real time and create custom data structures that enable powerful analytics and monitoring capabilities.
To learn more about OTTL, visit OpenTelemetry’s GitHub resources on:
Transform Example
In this example, the configuration removes all attributes except for(keep_keys) service.name, service.namespace, cloud.region, process.command_line.
This configuration also masks a password (replace_pattern) that appears on the command line, such as $env password=mysecret username=myusername python run-my-app.py.