OpenTelemetry Collector configuration for telemetry sanitization
The OpenTelemetry (OTel) Collector receives telemetry from instrumented services and can filter or transform it before export to SolarWinds Observability SaaS. Depending on instrumentation and configuration, spans and logs – especially free-text GenAI prompts, responses, and tool content – may contain sensitive data such as credentials, tokens, or email addresses. This page provides guidelines on OTel Collector processors for managing PII and other confidential parts of telemetry data, all in a centralized configuration.
Minimize sensitive data collection as early as possible
Start with data minimization: avoid generating sensitive telemetry when it is not needed, rather than relying on downstream sanitization. See the OpenTelemetry GenAI Semantic Conventions guidelines for capturing instructions, inputs and outputs and check the instrumentation or third-party framework you use for content capture configuration. When content must be collected, consider application-level guardrails such as Guardrails AI or Microsoft Presidio to inspect, redact, or reject sensitive input before it reaches the model. See also Generative AI instrumentation for Python.
Layered collector processor strategy
Collector processors can apply different policies to different signals: drop an entire span or log when appropriate, then remove or redact selected attributes in remaining telemetry. Processor order can affect results, so test your collector pipelines against representative telemetry.
Dropping spans can result in orphaned telemetry. Changing resource attributes can break entity inference. Please verify the processed telemetry in SolarWinds Observability before rollout.
There is no universal copy-and-paste sanitization configuration that is safe for every use case. The data that must be retained or removed depends on the application, observability needs, and your privacy policy. The examples here are starting points that can be adapted based on processor documentation in OpenTelemetry Collector Contrib. See also the OpenTelemetry Collector configuration guide.
Ensure you have registered your configured processors in your service pipelines. For example:
receivers:
otlp/notls:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
processors:
# Drop whole spans/logs if flagged with custom action attribute
filter:
error_mode: propagate
trace_conditions:
- span.attributes["privacy.action"] == "drop"
# Redact email patterns in values
redaction:
allow_all_keys: true
blocked_values:
# Example email pattern; mask the part of the value that matches
- "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
masking_string: "<REDACTED>"
exporters:
debug:
verbosity: detailed
service:
pipelines:
traces:
receivers: [otlp/notls]
processors: [filter, redaction]
exporters: [debug]
Remove telemetry with the Filter Processor
The Filter Processor drops whole telemetry items when a configured condition matches. Its conditions use OpenTelemetry Transformation Language (OTTL) so the processor can drop telemetry at various levels, from spans/logs/metrics up through scope and resource. See the OTTL language guide for additional condition syntax. Here is an example that will drop spans and logs if they’re marked with a custom attribute, privacy.action, as drop:
processors:
# Drop whole spans/logs if flagged with custom action attribute
filter:
# If a condition error, returns the error upstream and drops telemetry
error_mode: propagate
trace_conditions:
- span.attributes["privacy.action"] == "drop"
log_conditions:
- log.attributes["privacy.action"] == "drop"
Remove or mask sensitive attributes with the Redaction Processor
The Redaction Processor acts on policies that apply to signal-level, scope and resource attributes. It can remove attributes if not on the allowlist, leave trusted attributes unchanged, and redact values that match configured key or value patterns.
Exclude attributes by key with allowlist
All attributes are deleted by default because the default for allow_all_keys is false. A defined allowed_keys list means that any key not on the list has its attribute removed from a span/metric/log – designed to “fail closed”. However, if you need to retain attributes that are confirmed as trusted and do not require redaction, add them to the ignored_keys or ignored_key_patterns list. These do not need to be on allowed_keys list.
processors:
redaction/attribute_allowlist:
allow_all_keys: false # default
allowed_keys:
- service.name
- gen_ai.operation.name
# Trusted attributes are exceptions that pass through unchanged, even though they are not allowlisted.
ignored_keys:
- deployment.environment.name
ignored_key_patterns:
- "^trusted\\."
Alternatively: opt into allowing all attributes
You may set allow_all_keys: true to retain all attributes instead. This can simplify configuration if the goal is to redact only specific attributes. See masking or hashing, described below.
Determine which of the allowed attributes should be redacted
Once the allowed attributes are selected, their values will be redacted if their keys or values match conditions set by additional Redaction Processor configuration.
If an attribute key in allowed_keys also matches one of the blocked_key_patterns, then its entire value will be masked or hashed (see next section).
For a string-valued allowed attribute, if its value matches one of the patterns in blocked_values, then the part that matches will be masked or hashed; the rest of the attribute value stays the same. By default, value-pattern redaction does not inspect non-string attribute values, including arrays. Set redact_all_types: true to inspect their string representations; values modified by redaction are then stored as strings.
allowed_values provides patterns that are exceptions to what also matches blocked_values. If match is in both allowed_values and blocked_values, allowed_values takes precedence to maintain the allowlist design.The full attribute value matching the allowed value is retained without redaction. For example:
processors:
redaction:
allowed_keys:
- custom.email.from
- custom.email.to
- custom.email.cc
blocked_values:
# Mask addresses at mycompany.com; only redact the matching substring
- "[A-Za-z0-9._%+-]+@mycompany\\.com"
allowed_values:
# Exception: the support mailbox is not redacted; retains the entire attribute
- "^support@mycompany\\.com$"
Configure global attributes masking or hashing
How all allowed-but-blocked attributes should be redacted is a global for all matching attributes. Note that Redaction Processor supports masking or hashing, but not both at once, so only configure one.
masking_string is the string that will replace substring matches with blocked_values, or the entire value if matched with blocked_key_patterns. The default mask is “****”, and masking is the default behaviour unless hash_function is set. This type of redaction avoids cryptographic work, but does replace unique/distinct parts of telemetry data with constants.
processors:
redaction/mask_sensitive_values:
allow_all_keys: true
blocked_values:
# Example email pattern; mask the part of the value that matches
- "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
blocked_key_patterns:
# Match keys containing lowercase "token" or "api_key"; mask the whole value.
- ".*(token|api_key).*"
masking_string: "<REDACTED>"
Hashing of attributes with HMAC can maintain more heterogeneity in telemetry data, while providing a layer of protection over values such as email addresses, phone numbers, and IP addresses. Enable this by setting hash_function to hmac-sha256 or hmac-sha512 and hmac_key to a secret, for example an environment variable such as ${env:REDACTION_SECRET_KEY}.
processors:
redaction/hash_email:
allow_all_keys: true
blocked_values:
# Example email pattern; matching portions are replaced with their HMAC.
- "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
hash_function: hmac-sha256
# Store a secret of at least 32 bytes in the environment or a secret manager.
hmac_key: "${env:REDACTION_SECRET_KEY}"
Additional specialized URL, database query redaction configuration
The processor supports redaction of URL and database query telemetry with specialized sanitizers, without having to come up with and maintain regexes for attribute keys and values from scratch. See url_sanitizer and db_sanitizer for more information.
processors:
redaction/sanitize_urls_and_queries:
allow_all_keys: true
url_sanitizer:
enabled: true
attributes: ["url.full", "http.url"]
sanitize_span_name: false
db_sanitizer:
sanitize_span_name: true
sql:
enabled: true
attributes: ["db.statement", "db.query", "db.query.text"]
Use OTTL and the Transform Processor for handling context-dependent attributes
The OpenTelemetry collector Transform Processor supersedes the Attributes Processor and Resource Processor, as the latter will be removed by v0.167.0. See pull request.
Use the Transform Processor when a change depends on context – for example, redact an attribute only for production resources, or delete a field only for a particular span name or route. Its OpenTelemetry Transformation Language (OTTL) statements can conditionally set, replace, or delete specific fields while leaving unrelated attributes intact. By contrast, the Redaction Processor is more convenient for broad allowlists and common key/value masking or hashing policies; it does not support arbitrary OTTL conditions.
processors:
transform:
error_mode: propagate
trace_statements:
# Replace email matches in the custom gen_ai.if_prod.transform span attribute when the custom deployment span attribute is "production" or "prod".
# Delete the custom gen_ai.if_prod.delete span attribute when the custom deployment span attribute is "prod".
- replace_pattern(span.attributes["gen_ai.if_prod.transform"], "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}", "<REDACTED>") where ContainsValue(["production", "prod"], span.attributes["deployment"])
- delete_key(span.attributes, "gen_ai.if_prod.delete") where span.attributes["deployment"] == "prod"
Troubleshooting
Start by checking the configuration. The Collector configuration guide describes the configuration structure and processors. These examples require a Collector distribution that includes the Redaction Processor, such as otelcol-contrib. Install an appropriate collector binary from the release list for your operating system, then replace otelcol in the commands below with your distribution's executable name.
-
Run
otelcol validate --config=customconfig.yamlto check the configuration file. -
Run
otelcol print-config --config=customconfig.yamlto inspect the effective configuration.
If the configuration is valid but the pipeline is not behaving as expected, check the Collector's runtime behavior.
-
The Collector troubleshooting guide covers common issues and the debug exporter, which can help compare telemetry before and after processing.
-
Collector internal telemetry includes
otelcol_processor_incoming_itemsandotelcol_processor_outgoing_items. Filter these by processor and signal to find item-count changes; they do not show modified attribute values. The internal logs guide explains how to increase log detail.
For rule-level debugging, use the documentation for the processor involved.
-
The Transform Processor's Troubleshooting and Self-observability sections explain how log level and
error_modeaffect diagnostics. Debug logs include statement conditions and theTransformContextbefore and after execution. -
The Redaction Processor's audit tables show which attributes were removed, masked, allowed, or ignored. A log-body audit table and example are also available. Set
summary: debugto include affected key names and counts,summary: infofor counts only, orsummary: silentto omit the summary. Key names in debug summaries can be sensitive.
For isolated tests, ottl.run (the open-source OTTL Playground) can help evaluate transform and filter expressions. It does not emulate Redaction Processor policies. OTelBin provides a visual view of pipeline wiring and can help identify configuration errors; validate the configuration with the Collector distribution you deploy as well.
To inspect a running pipeline, otel-tui displays traces, metrics, and logs, while the OTel Desktop Viewer is for traces. The OpenTelemetry telemetry generator can send sample telemetry to the Collector so you can reproduce and inspect a case.
Use synthetic or otherwise safe test data when debugging. Debug exporters, verbose logs, hosted tools, and redaction summaries can expose unsanitized values or sensitive attribute names.