Install, configure, and manage Fluentd data collector.
- Installs
td-agent
package - Generates configuration file
td-agent.conf
- Generates custom configuration files and saves them to
config.d/
- Manages
td-agent
service - Installs Fluentd gem plugins
As of the latest update, we are dropping support for Fluentd/TD Agent 3. Please ensure you are using Fluentd/TD Agent 4 or later.
Install and start the service.
class { 'fluentd': }
Receive logs from other Fluentd instances and via UNIX domain socket. Forward the logs to Elasticsearch.
include fluentd
fluentd::plugin { 'fluent-plugin-elasticsearch': }
fluentd::config { '500_elasticsearch.conf':
config => {
'source' => [
{
'type' => 'forward',
},
{
'type' => 'unix',
'path' => '/tmp/td-agent/td-agent.sock',
},
],
'match' => {
'tag_pattern' => '**',
'type' => 'elasticsearch',
'index_name' => 'foo',
'type_name' => 'bar',
'logstash_format' => true,
}
}
}
Read logs from UNIX domain socket, then forward them to Fluentd aggregators.
include fluentd
fluentd::config { '600_forwarding.conf':
config => {
'source' => {
'type' => unix,
'path' => '/tmp/td-agent/td-agent.sock',
},
'match' => {
'tag_pattern' => '**',
'type' => forward,
'server' => [
{ 'host' => 'example1.com', 'port' => 24224 },
{ 'host' => 'example2.com', 'port' => 24224 },
]
}
}
}
Defining Fluentd resources in Hiera.
fluentd::plugins:
'fluent-plugin-http':
plugin_ensure: 0.1.0
'fluent-plugin-elasticsearch':
plugin_ensure: present
fluentd::configs:
'100_fwd.conf':
config:
source:
type: forward
'200_stdout.conf':
config:
match:
tag_pattern: test
type: stdout
All configs employ a numbering system in the resource's title that is used for
ordering. When titling your config, make sure you prefix the filename with a
number, for example, 999_catch_all.conf
, 500_elasticsearch.conf
(999 has
smaller priority than 500)
fluentd
: Main class, includes all other classes.
fluentd::install
: Handles the packages.fluentd::service
: Handles the service.
The following parameters are available in the fluentd
class:
Default value: true
Default value: 'treasuredata'
Default value: 'TreasureData'
Default value: 'https://packages.treasuredata.com/2/redhat/$releasever/$basearch'
Default value: true
Default value: true
Default value: 'https://packages.treasuredata.com/GPG-KEY-td-agent'
Default value: 'C901622B5EC4AF820C38AB861093DB45A12E206F'
Default value: 'td-agent'
Default value: present
Default value: 'td-agent'
Default value: running
Default value: true
Default value: true
Default value:
- when
$facts['osfamily'] == 'redhat'
: redhat - otherwise: undef
Default value: '/etc/td-agent/td-agent.conf'
Default value: '/etc/td-agent/config.d'
Default value: 'td-agent'
Default value: 'td-agent'
Default value: {}
Default value: {}
Exclusively handle config files into fluentd::conf_dir
. If true
config files not created by puppet will be removed, default to false
.
fluentd::config
: Generates custom configuration files.fluentd::plugin
: Installs plugins.
The following parameters are available in the fluentd::plugin
defined type:
Plugin name
Default value: present
Default value: 'https://rubygems.org'
Default value: tdagent
Default value: [] see https://docs.puppetlabs.com/puppet/latest/reference/type.html#package-provider-gem, e.g.
plugin_install_options => [{'--http-proxy' => $http_proxy}]
The following parameters are available in the fluentd::config
defined type:
Config filename
Config Hash, please see usage examples.
Tested on CentOS 6, CentOS 7, Ubuntu 14.04, Debian 7.8
Bug reports and pull requests are welcome!
$ bundle install
$ bin/rake lint
$ bin/rake metadata_lint
$ bin/rake spec
$ bin/rspec spec/lib
$ bin/rake beaker BEAKER_set=centos-6-x64
$ bin/rake beaker BEAKER_set=centos-7-x64
$ bin/rake beaker BEAKER_set=debian-7-amd64
$ bin/rake beaker BEAKER_set=ubuntu-server-1404-x64