Apache access and error logs in Fluentd

To parse and add Apache2 access and error logs add this section to your /etc/td-agent/td-agent.conf Fluend config file


<source>
  @type tail
  path /var/log/httpd/access_log
  pos_file /var/log/td-agent/apache2.access_log.pos
  format apache2
  tag my.apache.access
</source>

<source>
  @type tail
  path /var/log/httpd/error_log
  pos_file /var/log/td-agent/apache2.error_log.pos
  format apache_error
  tag my.apache.error
</source>

<match my.**>
  @type elasticsearch
  include_tag_key true
  logstash_format true
  host localhost
  port 9200
  logstash_prefix apache
</match>

Restart td-agent


/etc/init.d/td-agent restart
Restarting td-agent (via systemctl):                       [  OK  ]

Now, access apache web pages and you will see logs going into elastic database.

In Kibana management, create new index pattern like apache-* to visualize apache logs in kibana