python_info, process_open_fds, process_cpu_seconds_total, etc.) that you likely do not want to collect. Below is a small excerpt of scraped output showing both useful and noisy metrics:
current_temperature_fahrenheit_degF and current_humidity_percentage) using the filter processor.
Overview
- Add a
filterprocessor underprocessors. - Configure rules for metrics (either
includeorexclude) and choose amatch_type(strict,regexp,expr). - Wire the processor into the service pipeline so it runs for the intended telemetry type.
- Prefer
regexpfor flexible pattern matching.
Processor ordering matters: filter early in the pipeline (usually before heavy processors like
batch or attributes) so unwanted telemetry is removed as soon as possible.Common startup errors stem from typos in the configuration keys. For example, use
metric_names (not metric_namees). If the Collector fails on restart, inspect logs for configuration parse errors.Filter out metric names with a regular expression
Below is a minimal example that excludes metrics whose names start withpython or process. Note the correct key is metric_names.
filter processor is included in your metrics pipeline so it executes:
scrape_samples_scraped after applying the filter, either update the regex to exclude them or switch to an include-only strategy (see the next section).
After the filter is applied, expected Collector output should include only application metrics like:
Include-only vs Exclude — which approach to use?
- Exclude approach: use
excludeto remove undesired metrics by pattern. Useful when noise is limited to a few predictable prefixes. - Include approach: use
includeto allow only the named metrics you want. Safer when you want to strictly control which metrics are collected.
current_temperature_fahrenheit_degF and current_humidity_percentage:
Filtering logs by severity
The filter processor can target logs as well. If your application emits logs at many severities (DEBUG, INFO, WARN, ERROR, FATAL) and you want to collect only ERROR and above, configure the logs section of the filter processor. Example log severity samples:Full processors example (combined)
A consolidated processors block that demonstrates metrics exclusion, logs inclusion, batching, and an attributes inserter:- Place the filter processor early in pipelines to minimize downstream processing on unwanted telemetry.
- Prefer
match_type: regexpfor flexible pattern-based rules. - Use include-only when you require strict control over which metrics are collected.
- Double-check configuration key names to avoid parse errors (e.g.,
metric_names).
- OpenTelemetry Collector filter processor docs: https://opentelemetry.io/docs/collector/
- OpenTelemetry Collector contrib repo: https://github.com/open-telemetry/opentelemetry-collector-contrib
- The filter processor provides powerful include/exclude rules for metrics and logs.
- Use regex patterns for flexible matching and include-only for tight control.
- Verify processor ordering and configuration keys to avoid startup issues.