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 tail
path /var/log/nginx/access.log
pos_file /var/log/access.log.pos
format nginx
</source>
To organize and identify these logs effectively, you can assign a specific tag using the tag
property in the configuration. Here's how you can set it:
<source>
@type tail
path /var/log/nginx/access.log
pos_file /var/log/access.log.pos
tag nginx.access
format nginx
</source>
In this example, the logs are tagged with nginx.access
. This tag is crucial as it allows you to filter or match logs based on it in subsequent Fluentd configurations.
Now, with the tag defined, it can be referenced in a match
or filter
directive. Here's an example of using the match
directive to forward all logs with the nginx.access
tag to standard output:
<source>
@type tail
path /var/log/nginx/access.log
pos_file /var/log/access.log.pos
tag nginx.access
format nginx
</source>
<match nginx.access>
@type stdout
</match>
This setup ensures that all log events tagged as nginx.access
are directed to the standard output, providing a streamlined way to manage and view these specific logs.
🔠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 Rotate Log Files in Fluentd?
Fluentd offers the capability to set up log rotation, particularly useful when managing large volumes of logs that consume significant disk space. This feature can be configured through Fluentd's s...
Questions -
Fluentd vs Logstash
Explore log collectors Fluentd & Logstash, comparing their features and performance to determine the optimal choice for your log collection and management needs.
Comparisons -
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
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 usBuild 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