4.1 Configuration
In this step, we’ll modify agent.yaml
to include the attributes
and redaction
processors. These processors will help ensure that sensitive data within span attributes is properly handled before being logged or exported.
Previously, you may have noticed that some span attributes displayed in the console contained personal and sensitive data. We’ll now configure the necessary processors to filter out and redact this information effectively.
Attributes:
-> user.name: Str(George Lucas)
-> user.phone_number: Str(+1555-867-5309)
-> user.email: Str(george@deathstar.email)
-> user.account_password: Str(LOTR>StarWars1-2-3)
-> user.visa: Str(4111 1111 1111 1111)
-> user.amex: Str(3782 822463 10005)
-> user.mastercard: Str(5555 5555 5555 4444)
{"kind": "exporter", "data_type": "traces", "name": "debug"}
Exercise
Switch to your Agent terminal window and open the agent.yaml
file in your editor. We’ll add two processors to enhance the security and privacy of your telemetry data.
1. Add an attributes
Processor: The Attributes Processor allows you to modify span attributes (tags) by updating, deleting, or hashing their values. This is particularly useful for obfuscating sensitive information before it is exported.
In this step, we’ll:
- Update the
user.phone_number
attribute to a static value("UNKNOWN NUMBER")
. - Hash the
user.email
attribute to ensure the original email is not exposed. - Delete the
user.password
attribute to remove it entirely from the span.
attributes/update:
actions: # Actions
- key: user.phone_number # Target key
action: update # Update action
value: "UNKNOWN NUMBER" # New value
- key: user.email # Target key
action: hash # Hash the email value
- key: user.password # Target key
action: delete # Delete the password
2. Add a redaction
Processor: The Redaction Processor detects and redacts sensitive data in span attributes based on predefined patterns, such as credit card numbers or other personally identifiable information (PII).
In this step:
We set
allow_all_keys: true
to ensure all attributes are processed (if set tofalse
, only explicitly allowed keys are retained).We define
blocked_values
with regular expressions to detect and redact Visa and MasterCard credit card numbers.The
summary: debug
option logs detailed information about the redaction process for debugging purposes.
redaction/redact:
allow_all_keys: true # If false, only allowed keys will be retained
blocked_values: # List of regex patterns to block
- '\b4[0-9]{3}[\s-]?[0-9]{4}[\s-]?[0-9]{4}[\s-]?[0-9]{4}\b' # Visa
- '\b5[1-5][0-9]{2}[\s-]?[0-9]{4}[\s-]?[0-9]{4}[\s-]?[0-9]{4}\b' # MasterCard
summary: debug # Show debug details about redaction
Update the traces
Pipeline: Integrate both processors into the traces
pipeline. Make sure that you comment out the redaction processor at first (we will enable it later in a separate exercise). Your configuration should look like this:
traces:
receivers:
- otlp
processors:
- memory_limiter
- attributes/update # Update, hash, and remove attributes
#- redaction/redact # Redact sensitive fields using regex
- resourcedetection
- resource/add_mode
- batch
exporters:
- debug
- file
- otlphttp