🔠Want to centralize and monitor your logs?
Go to Logtail and start your log management in 5 minutes.
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 system-wide settings.
Here is an example of a log rotation configuration in Fluentd that can rotate logs daily:
<system>
<log>
rotate_age 7
rotate_size 1048576
</log>
</system>
The configuration options are as follows:
rotate_age
: This parameter specifies the maximum age of log files in days before they are rotated. In this example, logs older than seven days will be rotated.
rotate_size
: This option defines the maximum file size in bytes for a log file before it gets rotated. Here, the file size threshold for rotation is set at 1MB.
Additionally, the rotate_age
option can accept string values for more dynamic scheduling:
<system>
<log>
rotate_age weekly
rotate_size 1048576
</log>
</system>
Setting rotate_age
to "weekly" means that the files will be rotated every week.
These settings are not limited to configuration files. You can also pass them as command-line arguments:
fluentd -c fluent.conf --log-rotate-age 7 --log-rotate-size 104857600
Go to Logtail and start your log management in 5 minutes.
Conditional statements can be seamlessly integrated into Fluentd's record_transformer plugin. Here’s how you can do it: <filter mylogs> @type recordtransformer enableruby true <record> is...
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...
Fluentd, starting from version v1.13.0, allows the integration of environment variables within its configuration using the syntax #{ENV['YOUR_ENV_VARIABLE']}. For instance, if you've defined an env...
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> ...
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 usWrite 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