Use the OpenTelemetry Collector’s filter processor to drop routine probe logs and low-severity noise before export. Then use the transform processor to mask sensitive text and delete or hash selected attributes before the Collector batches the surviving records for Hosted OpenTelemetry.
Start with a rule you can verify in OpenSearch Dashboards Discover. In the demonstration below, successful probes disappear while a failed readiness check and a payment error stay searchable.
Contents
Decide what the rules must keep
Take a recent slice of one service’s logs and identify an event you would be comfortable losing, an event you would need during an incident and an event you would keep only with a value removed. In this example those are a successful readiness probe, a failed readiness probe and a payment failure that carries a test card number. Write down the expected result for each before you change the Collector. That gives you something more specific to check than whether the ingest chart went down.
The probe rule below only drops successful GET requests to the exact paths /healthz and /ready from the access log, with a 2xx status and INFO severity. A GET /ready 503 can be the first evidence that a deployment lost a dependency. A request to /healthz-extra follows a different route. Both are fixtures in the test. The chatty component rule keeps warnings and errors from the same component, and the severity rule starts at TRACE so a record with an unset severity stays eligible for investigation.
Build the rule around what the receiver actually emits. The Collector sees an OpenTelemetry log body, log attributes and resource attributes. Discover sees indexed fields after ingestion. A line that reads “DEBUG cache lookup” might have no numeric severity if the receiver kept the entire line as text. Likewise, a status field displayed in Discover could be added during collection or downstream. Verify the data in the Collector before borrowing a field name from a search.
Put the processors in export order
The logs pipeline runs its listed processors in order. Put memory_limiter first so the Collector can push back when memory is under pressure. Run filter/noise next to drop complete records, then transform/scrub on the survivors. Put batch last to group the logs that are ready for export. This keeps regex work off records you already intend to discard and keeps both filtering and masking ahead of the outbound exporter.
Start with Collector Contrib 0.161.0, the version pinned in the server log files guide. The full configuration below uses the same otlp_http/logit and basicauth/logit wiring as the Hosted OpenTelemetry quickstart. For your stack, copy the HTTPS base URL and credentials from Endpoints. Use the Basic auth username {stackId}-otel and the Hosted OpenTelemetry API key as the password. Hosted OpenTelemetry is available on all plans and on by default for new Logs stacks. On an older stack, an account owner or administrator, or a stack administrator, opens Endpoints, selects Switch on in the Hosted OpenTelemetry card and confirms. Skip this step if the card already shows the endpoint details. The hostname follows the stack ID plus -otel.logit.io format and uses OTLP over HTTP on port 443. The exporter adds /v1/logs to the base URL. See the Hosted OpenTelemetry quickstart and the server log files guide. The server log files guide still shows the older filelog alias, and 0.161.0 accepts file_log.
Save this as collector.yaml in a scratch directory. The endpoint is a placeholder. The receiver reads two synthetic files from the working directory and starts at the beginning so a fresh run reads both files from the start. It parses the timestamp and level, moves the parsed message into the log body and retains the request and component fields as log attributes. Keep your existing receiver paths and resume behaviour when you adapt the processor blocks to a running Collector.
# Tested with otelcol-contrib 0.161.0.
extensions:
basicauth/logit:
client_auth:
username: "${env:LOGIT_OTEL_USERNAME}"
password: "${env:LOGIT_OTEL_PASSWORD}"
receivers:
file_log/checkout:
include: [./demo-logs/app.log, ./demo-logs/access.log]
start_at: beginning
include_file_name: true
resource:
service.name: checkout-demo
service.instance.id: "${env:DEMO_INSTANCE:-checkout-canary}"
operators:
- type: json_parser
timestamp:
parse_from: attributes.time
layout: "%Y-%m-%dT%H:%M:%SZ"
- type: severity_parser
if: 'attributes.level != "UNSPECIFIED"'
parse_from: attributes.level
- type: move
from: attributes.message
to: body
- type: remove
field: attributes.time
- type: remove
field: attributes.level
processors:
memory_limiter:
check_interval: 1s
limit_mib: 256
spike_limit_mib: 64
filter/noise:
error_mode: ignore
log_conditions:
- >
log.severity_number >= SEVERITY_NUMBER_TRACE and
log.severity_number < SEVERITY_NUMBER_INFO
- >
log.attributes["log.file.name"] == "access.log" and
log.attributes["http.request.method"] == "GET" and
(log.attributes["url.path"] == "/healthz" or log.attributes["url.path"] == "/ready") and
(IsInt(log.attributes["http.response.status_code"]) or
IsDouble(log.attributes["http.response.status_code"])) and
log.attributes["http.response.status_code"] >= 200 and
log.attributes["http.response.status_code"] < 300 and
log.severity_number >= SEVERITY_NUMBER_INFO and
log.severity_number < SEVERITY_NUMBER_WARN
- >
log.attributes["component"] == "cache-heartbeat" and
log.severity_number >= SEVERITY_NUMBER_INFO and
log.severity_number < SEVERITY_NUMBER_WARN
transform/scrub:
error_mode: propagate
log_statements:
- 'delete_matching_keys(log.attributes, "(?i)^(authorization|http\\.request\\.header\\.authorization)$$")'
- 'replace_pattern(log.body, "(?i)\\bbearer[ \\t]+[A-Za-z0-9._~+/-]+=*", "Bearer [REDACTED_TOKEN]") where IsString(log.body)'
- 'replace_pattern(log.body, "(?i)([?&](?:api_key|apikey)=)[^&#\\s\"]+", "$$1[REDACTED_QUERY]") where IsString(log.body)'
- 'replace_pattern(log.body, "(?i)[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,}", "[REDACTED_EMAIL]") where IsString(log.body)'
- 'replace_pattern(log.body, "\\b[0-9]{4}[ -]?[0-9]{4}[ -]?[0-9]{4}[ -]?[0-9]{4}\\b", "[REDACTED_CARD]") where IsString(log.body)'
- 'set(log.attributes["user.email_hash"], SHA256(log.attributes["user.email"])) where IsString(log.attributes["user.email"])'
- 'delete_key(log.attributes, "user.email")'
batch: {}
exporters:
otlp_http/logit:
endpoint: https://abc12345-otel.example
auth:
authenticator: basicauth/logit
service:
extensions: [basicauth/logit]
pipelines:
logs:
receivers: [file_log/checkout]
processors: [memory_limiter, filter/noise, transform/scrub, batch]
exporters: [otlp_http/logit]
The low-severity condition drops every TRACE and DEBUG record in this pipeline, whatever its content. If any service logs real failures at DEBUG, scope or remove that condition before rollout.
Each condition in log_conditions can independently drop a record. Keep the file, method, path, status and severity checks for the probe rule in one expression joined by and. The rule accepts integer and double status values because the JSON receiver emitted these fixture statuses as doubles. Keep the numeric check when adapting the rule so an absent status or a string from another parser cannot qualify as a successful probe. The condition syntax and evaluation rules are in the filter processor reference for 0.161.0.
Mask only the values you can identify
Use a mask when the value is unnecessary for triage. The bearer rule preserves the word Bearer and replaces the token. The query rule preserves the parameter name and the other parameters, so an investigator can still see which route was called and how the request was shaped. The email and card rules preserve the surrounding message, including the fact that payment was rejected. They match the formats shown in the fixture. A URL inside a separate log attribute needs its own rule even if the body already looks clean.
Delete known sensitive keys independently of text replacement. The Authorization cleanup removes both the example header attribute spellings, including an array-valued copy. That leaves the Basic authentication on the export request intact because it is configured on the exporter extension. The email attribute is hashed for equality checks and the original attribute is then deleted. The hash is deterministic, so identical inputs yield identical values. Anyone with a guessable address can compute its hash. Drop the attribute and its hash if you have no approved use for correlation. The functions are documented in the transform processor reference for 0.161.0 and the OTTL function reference for 0.161.0.
| Rule | Collector input | Expected result |
|---|---|---|
| Low severity | log.severity_number from TRACE up to INFO, exclusive | Drop TRACE and DEBUG. Keep unspecified severity. |
| Successful probes | GET /healthz or /ready in the access file with INFO severity and a 2xx http.response.status_code | Drop the 200 and 204 records. Keep the 503 record. |
| Chatty component | component equals cache-heartbeat with INFO severity | Drop the routine heartbeat. Keep the late-heartbeat warning. |
| Body masks | Bearer tokens, api_key or apikey query parameter values, email addresses and card-like numbers in log.body | Keep the record with the matching text replaced. |
| Authorization cleanup | Authorization or http.request.header.authorization in log.attributes, matched without regard to case | Remove the entire key and its value. |
| Email attribute | String log.attributes["user.email"] | Write user.email_hash and remove user.email. |
Use application-side controls to avoid writing secrets to disk. Collector redaction limits what this pipeline sends onward. A card pattern can also match a harmless 16-digit identifier, and a bearer pattern can miss a token with a different delimiter. Put examples of both in the review fixture so a rule change gets judged on what it removes and what it leaves behind.
Run a debug-only fixture
From the directory containing the YAML, run this shell block to create the demonstration files. Every sensitive-looking value is fake. Keep the timestamps as written when you compare your output with the Discover examples. The two failing records, the late heartbeat and the unclassified line are deliberate controls. A test made entirely of junk lines tells you very little about the evidence your policy can preserve.
mkdir -p demo-logs
cat > demo-logs/app.log <<'JSON'
{"time":"2026-12-05T08:00:01Z","level":"TRACE","event.id":"app-01","message":"Cache lookup detail"}
{"time":"2026-12-05T08:00:02Z","level":"DEBUG","event.id":"app-02","message":"Request parser detail"}
{"time":"2026-12-05T08:00:03Z","level":"INFO","event.id":"app-03","component":"cache-heartbeat","message":"Cache heartbeat succeeded"}
{"time":"2026-12-05T08:00:04Z","level":"WARN","event.id":"app-04","component":"cache-heartbeat","message":"Cache heartbeat late"}
{"time":"2026-12-05T08:00:05Z","level":"INFO","event.id":"app-05","Authorization":"Bearer DEMO_ONLY.header","http.request.header.authorization":["Bearer DEMO_ONLY.array"],"user.email":"[email protected]","message":"Sign-in [email protected] used Bearer DEMO_ONLY.token"}
{"time":"2026-12-05T08:00:06Z","level":"ERROR","event.id":"app-06","message":"Payment rejected for test card 4111 1111 1111 1111"}
{"time":"2026-12-05T08:00:07Z","level":"INFO","event.id":"app-07","message":"Order confirmation queued"}
{"time":"2026-12-05T08:00:08Z","level":"UNSPECIFIED","event.id":"app-08","message":"Legacy checkout line without mapped severity"}
JSON
cat > demo-logs/access.log <<'JSON'
{"time":"2026-12-05T08:00:09Z","level":"INFO","event.id":"access-01","http.request.method":"GET","url.path":"/healthz","http.response.status_code":200,"message":"GET /healthz 200"}
{"time":"2026-12-05T08:00:10Z","level":"INFO","event.id":"access-02","http.request.method":"GET","url.path":"/ready","http.response.status_code":204,"message":"GET /ready 204"}
{"time":"2026-12-05T08:00:11Z","level":"ERROR","event.id":"access-03","http.request.method":"GET","url.path":"/ready","http.response.status_code":503,"message":"GET /ready 503"}
{"time":"2026-12-05T08:00:12Z","level":"WARN","event.id":"access-04","http.request.method":"GET","url.path":"/healthz-extra","http.response.status_code":404,"message":"GET /healthz-extra 404"}
{"time":"2026-12-05T08:00:13Z","level":"INFO","event.id":"access-05","http.request.method":"GET","url.path":"/checkout","http.response.status_code":200,"message":"GET /checkout?api_key=DEMO_ONLY_key&source=web 200"}
JSON
Save the following as debug-overlay.yaml. With both files supplied in this order, the overlay replaces the logs pipeline’s exporter list with just debug. The Hosted OpenTelemetry exporter remains defined in the base file but is unwired during this run. The detailed records appear in the terminal (stderr) without sending them to a stack.
exporters:
debug:
verbosity: detailed
service:
pipelines:
logs:
exporters: [debug]
export LOGIT_OTEL_USERNAME=example-user LOGIT_OTEL_PASSWORD=example-password
otelcol-contrib --version
otelcol-contrib validate --config collector.yaml --config debug-overlay.yaml
otelcol-contrib --config collector.yaml --config debug-overlay.yaml
Once the records appear in your terminal, stop the fixture Collector with Ctrl+C. Check for eight event IDs. app-01, app-02 and app-03 should be absent, as should access-01 and access-02. Check for the warning at app-04, the payment error at app-06 and the failed probe at access-03. In app-05, look for the two body masks, absence of the Authorization and raw email keys and presence of the email hash. Check the query parameter in access-05 separately. A clean body can still sit next to an unclean attribute.
Use detailed debug output only with synthetic data or samples you are permitted to expose on the machine. An unfiltered baseline can spill straight into terminal history captures or service logs if debug is enabled. When the fixture passes, run validate on the assembled Collector configuration you actually plan to reload, with that service’s environment variables in place.
Verify the counts and fields in Discover
From your Logs stack, choose Launch Logs and open Discover in OpenSearch Dashboards. Select logstash-* with @timestamp as the time field, then choose DQL in the query bar. Use an absolute before window and an equally long after window. Keep the same service and canary instance scope across both so activity from other Collectors cannot hide a change. Follow the OpenTelemetry for Logs guide to open the view.
Start with a service count. We processed the same 13 synthetic lines with a baseline policy and with the new policy. We indexed both sets in OpenSearch for this demonstration. Discover showed 13 hits before and eight after filtering. The screenshots scope those two runs to separate demonstration instance IDs in the same one-minute interval, 08:00 to 08:01 UTC on 5 December 2026. The queries below use after. For the demonstration baseline, change the instance ID to before. On your stack, use your service name. If you populate the instance field, keep the instance filter and set it to the canary instance you used in each window.
otel.resource.service.name.keyword: "checkout-demo" and
otel.resource.service.instance.id.keyword: "after"
Then count only the successful probes. Use exact keyword sub-fields for the method and path. The status comparison only works if http.response.status_code is mapped as a number: look for the # icon next to the field in the Discover sidebar. If it shows as text, search the .keyword field or the message text instead. Confirm the count against known probe rows in both windows for the exact service you are rolling out to.
otel.resource.service.name.keyword: "checkout-demo" and
otel.attributes.http.request.method.keyword: "GET" and
otel.attributes.url.path.keyword: ("/healthz" or "/ready") and
otel.attributes.http.response.status_code >= 200 and
otel.attributes.http.response.status_code < 300 and
otel.resource.service.instance.id.keyword: "after"


Check the error count independently. This query found two errors in each demonstration run. For an actual rollout, validate one expected error by looking at its row, since two equal counts can refer to different events.
otel.resource.service.name.keyword: "checkout-demo" and otel.severity_number >= 17 and
otel.resource.service.instance.id.keyword: "after"
Check the failed readiness probe separately. This query returned one record in each run.
otel.resource.service.name.keyword: "checkout-demo" and
otel.attributes.url.path.keyword: "/ready" and otel.attributes.http.response.status_code: 503 and
otel.resource.service.instance.id.keyword: "after"
For masking, select known test events and read their surviving messages. The following query selects the fixture’s token and email line, payment error and API-key request. Expand the rows and check the attributes as well. An existence search for the raw email keyword returned one hit in the baseline and zero after the change. Use a synthetic value for that kind of test so your search history never needs the real credential.
otel.resource.service.name.keyword: "checkout-demo" and
otel.attributes.event.id.keyword: ("app-05" or "app-06" or "access-05") and
otel.resource.service.instance.id.keyword: "after"
Use this existence query if your index mapping includes otel.attributes.user.email.keyword. Otherwise, expand the same known test event in both windows and confirm that otel.attributes.user.email is present in the baseline and absent after redaction. Search message separately to verify the body mask.
otel.resource.service.name.keyword: "checkout-demo" and otel.attributes.user.email.keyword: * and
otel.resource.service.instance.id.keyword: "after"

In these documents the log body was indexed as message, the event fields under otel.attributes.* and the service identity under otel.resource.*. Severity text was severity and the number was otel.severity_number when supplied. The legacy line had neither. Exact matches used keyword fields such as otel.attributes.event.id.keyword. The demonstrated message mapping was analysed text, so search it as text or look at the row. The available fields depend on the records and mappings in your stack.
Roll out with a canary and a rollback
Enable the change on one Collector or one clearly identified instance. Leave a comparable, already-scrubbed instance on the existing filter policy during the rollout if you can. That gives you a reference when request load changes with the deployment.
- Record the rollout time, the policy version and a reference count for the preceding window.
- Run the service, probe and error searches again after the canary receives comparable traffic. Include any on-call saved searches or alerts that depend on the fields you remove.
Filtering at the edge sends fewer records to your Logs stack. The fixture dropped five of 13 events, which tells you the policy matched five times. Measure your stack’s daily ingest in bytes over representative traffic to see the volume effect, since access lines, stack errors and other events can differ sharply in size. Logit.io Logs pricing is based on your selected daily volume and retention.
If an incident search loses the expected record, narrow or disable the filter on the canary and keep the verified masking stage in place. Records discarded at the edge never reached the stack. Recovery depends on whatever the application or host retained. When the canary passes, spread the change in stages and keep the control query handy for the next change to logging formats or severity mapping.
Troubleshoot the stage that failed
- Validation exits with an OTTL error. Read the component ID first. On 0.161.0, separating
>=into two tokens madevalidatereportprocessors::filter/noise, the position in the condition and the text near the error. A misspelled function yielded the same component ID and named the unsupported function. Fix malformed statements, undefined functions and bad path prefixes before restarting. For a rule that parses but matches the wrong text, check the string escaping at both the YAML and OTTL layer. The query mask uses$$1so the regex replacement gets the first captured group after configuration expansion. - The configuration validates and the rule has no effect. Look at the pipeline that feeds the exporter. Defining the processor under
processorsonly makes it available. The pipeline must list the same full component ID. If a receiver also feeds another logs pipeline, check the processors on that route. Export happens after the processors in each pipeline, so a second route can export an unscrubbed copy even when the first route is correct. - A filter matches nothing or drops too much. Check the debug record’s actual body, attributes and severity number. A plain text file input may leave the path and status in the body instead of in attributes. An unknown level may leave severity unset. If a failed request is missing, check the low-severity condition first.
A mask works in the fixture and misses production formats. Test mixed case, punctuation, encoded query parameter names, alternate separators and multi-line records.
Add a synthetic request such as
GET /checkout?api%5Fkey=DEMO_URL_ENCODED, and a JSON-in-string record whose decoded body still containsapi\u005fkey=DEMO_JSON_ESCAPED. Put the same fake value in a second place your receiver preserves, such as aurl.fullattribute or a nested map. Inspect what the Collector actually emits, adjust the rule for each location, rerun the debug fixture and confirm that the event survives and the fake value is absent from its body and every attribute.For a separate run, copy
collector.yamlanddebug-overlay.yamlinto a fresh scratch directory. Create an emptydemo-logs/app.logand save these two lines asdemo-logs/access.log.{"time":"2026-12-05T08:00:30Z","level":"INFO","event.id":"encoded-01","message":"GET /checkout?api%5Fkey=DEMO_URL_ENCODED 200","url.full":"/checkout?api%5Fkey=DEMO_URL_ENCODED"} {"time":"2026-12-05T08:00:31Z","level":"INFO","event.id":"encoded-02","message":"{\"request\":\"GET /checkout?api\\u005fkey=DEMO_JSON_ESCAPED\"}"}Run the debug commands with the published rules first. Both events survived in 0.161.0. The URL-encoded value remained in the body and in
url.full. The second body still contained the literal\u005fescape and its fake value.Append these statements to
log_statementsundertransform/scrub, at the same indentation as the existing rules. The first targets both encoded spellings in the body. The second targets the encoded copy inurl.full.- 'replace_pattern(log.body, "(?i)([?&]api(?:%5f|\\\\u005f)key=)[^&#\\s\"]+", "$$1[REDACTED_QUERY]") where IsString(log.body)' - 'replace_pattern(log.attributes["url.full"], "(?i)([?&]api%5fkey=)[^&#\\s\"]+", "$$1[REDACTED_QUERY]") where IsString(log.attributes["url.full"])'Rerun the debug commands and inspect both event IDs. Check the body and every attribute for the fake values. In this run both events survived again, with all three occurrences masked. If your receiver emits a structured body as a map, target its keys and test any nested attributes or original-message field it preserves.
- An unexpected runtime error appears. With
ignore, the filter logs a condition error and continues. Withpropagate, the transform returns a runtime statement error upstream and the affected payload can be lost. Usingignorefor redaction could let a value through after a statement fails. A pattern that simply misses its target, or a type guard that skips a statement, produces no such error. Keep negative examples in the fixture to test those cases explicitly.
Frequently asked questions
Why did the unclassified line survive?
Unspecified severity is zero and the filter’s lower bound is TRACE. Files that arrive without a parsed level would be especially vulnerable to a rule that only checks for severity below INFO. Decide what to do with that source once you can distinguish its ordinary records from incident evidence.
Why mask a value instead of dropping its event?
Keep the order failure, response code and timestamp when they support a diagnosis. Remove the value that has no place in the investigation. For example, a failed payment can still be counted and put on a timeline after its card-like text is masked.
When would I use the redaction processor?
Consider it for an explicit log-attribute allowlist. In Contrib 0.161.0 its logs support is alpha. An allowlist can remove fields your Discover searches need, so test it on a canary and keep body masking in the transform stage. See the redaction processor reference for 0.161.0.
Does the change affect logs already indexed?
The rules apply to records that pass through the Collector after the policy is active. If you find a previously exposed value in indexed logs or in a source file, handle that copy through your existing incident and retention process.
Can I use the same approach with an OTLP receiver?
Yes. Keep your receiver and exporter and wire in the processors on the existing logs pipeline. An application can supply structured bodies, numeric severity and attributes directly over OTLP. Use the debug exporter on a synthetic sample to confirm field types and paths before carrying over any file-specific conditions.
Unlock complete visibility with hosted ELK, Grafana, and Prometheus-backed Observability
Keep the canary queries with the policy so the next person can check what changed. The free trial gives you full access to every feature. Explore Logit.io Log Management for log ingestion, search and alerting.
