Collecting logs with fluentd
Contents
I’ve been collecting error logs with flume, but I’m switching to fluentd.actually the goal is monitoring, not collecting
Install
Just run the command shown on the site below and it handles everything including chkconfig registration.
Official site for reference
http://docs.fluentd.org/articles/install-by-rpm#step-0-before-installation
The architecture seems similar to flume
Set up client -> server, and logs collected on the client get forwarded to the server.
Run this command
| |
Start the service
| |
Obviously
service td-agent stopstops it
Configuration
/etc/td-agent/td-agent.conf is the config file
| |
Let’s keep it simple: collect only the error.log of each service and write them to a file on the log server.
The items I need for the setup I’m going for are:<source />: the data collection path, or receiving from a remote server
<match />: the action to handle collected logs (forward to another server or save to a local file)
Check the other config values at the link below (there are a lot..) http://docs.fluentd.org/articles/config-file#2-ldquomatchrdquo-tell-fluentd-what-to-do
Log collection td-agent.conf
| |
Log storage td-agent.conf
| |
If you get the error below on startup, give td-agent permission on the storage path
| |
| |
You can see files saved as error.timestamp in the folder below
| |
But it’s being saved as json. Probably inconvenient to read with the naked eye
Or there are lots of plugins, let’s look for one.