geerlingguy.fluentd
Ansible Role: Fluentd
This is an Ansible Role that helps you install Fluentd on RedHat/CentOS or Debian/Ubuntu systems. It installs td-agent
, a version of Fluentd that doesn't need Ruby separately installed. You can check the differences between td-agent and Fluentd here.
Requirements
None
Role Variables
Here are the available variables and their default values (see defaults/main.yml
):
fluentd_version
: 3
This specifies which version oftd-agent
to install. Learn more about the differences between v2, v3, and v4.fluentd_package_state
: present
This indicates the state of thetd-agent
package. Set it tolatest
if you want to upgrade or change versions.fluentd_service_name
: td-agentfluentd_service_state
: startedfluentd_service_enabled
: true
These control the options for the Fluentd service.fluentd_plugins
:- fluent-plugin-elasticsearch
Alternatively, you can specify plugins like this:
fluentd_plugins: - name: fluent-plugin-elasticsearch version: '4.0.6' state: present
This is a list of Fluentd plugins to install.
fluentd_conf_sources
: |
[default content is in defaults/main.yml]fluentd_conf_filters
: |
[default content is in defaults/main.yml]fluentd_conf_matches
: |
[default content is in defaults/main.yml]
These settings go into the td-agent.conf
file and control how Fluentd listens for, filters, and sends log data. The defaults provide basic settings that can direct data to Treasure Data, but you should change them to fit your log setup.
For instance, to monitor an Apache server’s access log, you would add a source like this:
fluentd_conf_sources: |
<source>
@type tail
@id input_tail
<parse>
@type apache2
</parse>
path /var/log/httpd-access.log
tag apache.access
</source>
Then, to send Apache logs to Elasticsearch, you would use:
fluentd_conf_matches: |
<match apache.**>
@type elasticsearch
host log.example.com
port 9200
user myuser
password mypassword
logstash_format true
</match>
Remember, Elasticsearch needs the fluent-plugin-elasticsearch
plugin to be installed.
Dependencies
None
Example Playbook
- hosts: search
vars:
fluentd_conf_sources: |
<source>
@type tail
@id input_tail
<parse>
@type apache2
</parse>
path /var/log/httpd-access.log
tag apache.access
</source>
roles:
- geerlingguy.fluentd
License
MIT / BSD
Author Information
This role was created in 2020 by Jeff Geerling, who wrote Ansible for DevOps.
Fluentd for Linux.
ansible-galaxy install geerlingguy.fluentd