A developer adds a debug line that logs the full request: email address, IP address, authorisation token. A week later, that data sits in storage with 35 days of retention, readable by anyone with access to logs. OpenPipeline data masking fixes the problem at the source: sensitive data is transformed at ingest, before it is stored in Grail.
The same pipeline also cuts cost: remove fields nobody reads, drop debug logs from a test environment, send chatty logs to a short-retention bucket. For an SRE, that means less toil (no more manual purges) and a compliance risk under control.
The goal of this tutorial: configure a log pipeline that masks IPs, emails and tokens, removes useless fields and drops worthless logs, then check the result with DQL. OpenPipeline relies on Grail: the content applies to Dynatrace SaaS. On Dynatrace Managed, masking goes through other mechanisms, covered in the FAQ.
Prerequisites
- A Dynatrace SaaS environment with Grail and OpenPipeline admin rights.
- Logs already ingested (OneAgent, API or OpenTelemetry); see the logs and OpenPipeline module for the basics.
- The list of data to protect, agreed with your DPO: emails, IPs, tokens, customer IDs.
- Access to Notebooks for verification.
How OpenPipeline processes a log
A record enters through an ingest source, is routed to a pipeline by a DQL condition, then goes through stages. The processing stage applies processors in order: DQL processor, remove fields, rename, drop record. Each processor has a matching condition (matcher) that limits it to the relevant records. A storage stage then picks the bucket, and therefore the retention.
Practical consequence: anything masked in the processing stage is never written in clear text to Grail. Masking applied later, in a query or a dashboard, protects nothing.
Configuring OpenPipeline data masking step by step
Step 1: create a pipeline and its route
On the OpenPipeline page, Logs section, create a pipeline named for example logs-app-paiement. Add a dynamic route with a condition that selects only the target logs:
matchesValue(k8s.namespace.name, "paiement")
Start with a narrow scope: one namespace or one application. Widen it once the result is checked.
Step 2: mask IP addresses
Add a DQL processor to the processing stage. To replace every IP address in the message:
fieldsAdd content = replacePattern(content, "IPADDR", "xxx.xxx.xxx.xxx")
If an address already sits in its own field and you want to keep the network for analysis, truncate it rather than wipe it:
fieldsAdd client.ip = ipMask(client.ip, 24)
ipMask(..., 24) sets the last octet to zero: you still know which network the traffic comes from, without identifying the machine. Adapt the field name (client.ip here) to your data.
Step 3: mask emails
A second DQL processor extracts the address, replaces it, then removes the temporary field:
parse content, "LD ([a-zA-Z0-9.!#$%&*+-/=?^_{|}~]+'@' LD '.' LD):email"
| fieldsAdd content = replaceString(content, email, "xxx@xxx.xxx")
| fieldsRemove email
Suggested matcher: contains(content, "@"). The processor then runs only on lines that may hold an address, which limits processing cost. This pattern handles the first address on the line: test it against your real formats with the processor preview.
Step 4: mask tokens
Bearer tokens often end up in access logs. A targeted DPL pattern replaces them:
fieldsAdd content = replacePattern(content, "'Bearer ' [a-zA-Z0-9._-]+", "Bearer ***")
Validate this pattern in the preview with samples from your own logs: token shapes vary from one identity provider to another.
Step 5: remove useless fields
Add a remove fields processor, or a DQL processor:
fieldsRemove http.request.header.cookie, debug.payload
Every stored attribute costs money, and a session cookie is sensitive data too. Remove whatever has not been used in a query for three months.
Step 6: drop worthless logs
Add a drop record processor with this matcher:
matchesValue(loglevel, "DEBUG") and matchesValue(deployment.environment, "test")
Those lines are not stored. For logs you want to keep, but not for long, use the storage stage instead: assign them to a short-retention bucket rather than dropping them.
How to check that it works
Generate a few test lines, wait one to two minutes, then run in a Notebook:
fetch logs, from:now()-30m
| filter k8s.namespace.name == "paiement"
| summarize {
total = count(),
ip_masquees = countIf(contains(content, "xxx.xxx.xxx.xxx")),
emails_masques = countIf(contains(content, "xxx@xxx.xxx")),
emails_restants = countIf(contains(content, "@") and not contains(content, "xxx@xxx.xxx"))
}
emails_restants must be zero. If not, display those lines with filter to see which format escapes the pattern. Also check that no DEBUG line from the test environment shows up, and that removed fields are gone from new records. Logs written before the pipeline was enabled remain unchanged.
To track the effect on ingested volume, compare the number of lines per day before and after the change, using the queries from log ingestion monitoring.
Best practices
- Mask as early as possible: in the application if you can, otherwise in the OpenTelemetry Collector, otherwise in OpenPipeline. Several layers beat one.
- Test with the preview of each processor before enabling the pipeline.
- Scope each processor with a matcher: fewer records processed, fewer surprises.
- Document masking rules for your DPO, and version the configuration (Monaco or Terraform).
- Keep useful context: masking a
trace_idwould break the link between logs and traces (see OpenTelemetry logs with trace_id).
Frequently asked questions
Does masking apply to logs already stored?
No. OpenPipeline acts at ingest. For data already stored, use Grail’s data deletion mechanisms, described in the documentation.
How do you mask sensitive data with Dynatrace Managed?
OpenPipeline is not available without Grail. On Managed, use the sensitive data masking options of OneAgent and log management, or mask in the OpenTelemetry Collector with the transform processor before sending.
Does dropping logs with drop record really lower the bill?
Dropped records are neither stored nor retained, which reduces retention and query volumes. The exact effect on the bill depends on your licensing model: check it against your contract and the consumption events.
Conclusion
A few well-targeted processors are enough: replacePattern and ipMask for IPs, a parse for emails, a pattern for tokens, fieldsRemove and drop record for volume. Check with DQL, document for compliance, and the next over-chatty debug line will not turn into a data incident.
span.observer is an independent community blog, not affiliated with Dynatrace LLC. Dynatrace is a trademark of its owner. Screen, processor and function names change over time: check them in the official documentation for your version.
Originally published on span.observer. French version: https://span.observer/fr/openpipeline-masquage-donnees-sensibles/.
Top comments (0)