Filtering events in Filebeat removes records or fields before the Beat publishes them. Use it for debug messages, health-check requests, or noisy payload fields that should not consume Elasticsearch storage or appear in dashboards and alerts.
Filebeat uses processors to change each event before it reaches the configured output. The drop_event processor removes the whole event when a when condition matches, and drop_fields removes named fields from events that still need to be shipped.
On Linux package installs, global processor rules usually live in /etc/filebeat/filebeat.yml and require a successful config test before the filebeat service is restarted. Keep drop_event conditions narrow, because dropped events cannot be recovered by Logstash, ingest pipelines, or later index rules.
$ sudo cp /etc/filebeat/filebeat.yml /etc/filebeat/filebeat.yml.bak
Restore the previous settings with sudo cp /etc/filebeat/filebeat.yml.bak /etc/filebeat/filebeat.yml if the updated configuration does not validate.
$ sudoedit /etc/filebeat/filebeat.yml
processors:
- drop_event:
when:
or:
- equals:
log.level: "debug"
- regexp:
message: '^GET /healthz\b'
- drop_fields:
fields:
- "trace.debug_id"
- "http.request.body.content"
ignore_missing: true
A top-level processors list affects every input. Put the same list under one input when only that source should use the filter.
Related: How to configure a filestream input in Filebeat
Elastic recommends placing drop and rename processors near the end because later processors cannot read fields that were already removed.
drop_event requires a when condition, and a broad match discards events before any output, Logstash pipeline, or Elasticsearch ingest pipeline sees them. drop_fields cannot remove @timestamp or type.
$ sudo filebeat test config -c /etc/filebeat/filebeat.yml Config OK
Related: How to test a Filebeat configuration
$ sudo systemctl restart filebeat
$ sudo systemctl is-active filebeat active
Search for the same fields used in drop_event, such as log.level: debug or message: “GET /healthz”. Existing indexed documents may still appear, so filter the search to a time range after the restart.
$ sudo journalctl -u filebeat.service --since "10 min ago" --no-pager --lines=80
Look for YAML parsing errors, field names that do not exist in the event, or a condition that matches more events than intended.