To selectively filter log events in Fluentd, you can use the <match>
directive to specify which events to process and which to discard. Here's how you can do it:
To discard all events that match a specific tag and process all other tags, you can configure Fluentd like this:
<match the.tag.you.want.to.drop>
@type null
</match>
<match **>
# process everything else
</match>
The null
output plugin effectively discards all log events that match the specified tag.
On the other hand, if you want to drop all events except those with a specific tag, the configuration would look like this:
<match the.tag.you.want.to.process>
# process this specific tag
</match>
In this setup, only the events matching the.tag.you.want.to.process
are processed, and all others are ignored. However, Fluentd will issue a warning for unprocessed tags.
To eliminate this warning and explicitly discard all other log events, you can direct them to the null
output plugin, like this:
<match the.tag.you.want.to.process>
# process this specific tag
</match>
<match **>
@type null
</match>
This approach ensures a clean configuration where specific tags are processed, and all others are silently discarded, maintaining an efficient log management system.
🔠Want to centralize and monitor your logs?
Go to Logtail and start your log management in 5 minutes. [/summary]
-
Fluentd
Learn how to use Fluentd to collect, process, and ship log data at scale, and improve your observability and troubleshooting capabilities.
Guides -
How to Add Tags to My Fluentd Events
Here is how you can add tags to Fluentd events. Let's assume you configured Fluentd to process Nginx access logs from the access.log file with a source configuration like this: <source> @type ta...
Questions -
How to Parse Nested JSON Fields in Fluentd
Learn how to configure Fluentd for nested JSON parsing in log messages for enhanced structured logging
Questions -
How to Send Logs to Multiple Outputs With Same Match Tags in Fluentd?
To direct logs matching a specific tag to multiple outputs in Fluentd, the @type copy directive can be utilized. Here's an example configuration: <match pattern> @type copy <store> ...
Questions
Make your mark
Join the writer's program
Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.
Write for us![](/assets/articles/authors/marin-0d19fe482115fe2b15c8429a7ee4eb88d803984eaa7c1d8c7309241049f3d402.png)
Build on top of Better Stack
Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.
community@betterstack.comor submit a pull request and help us build better products for everyone.
See the full list of amazing projects on github