1
0
mirror of https://github.com/krislamo/puppet-fluentd synced 2024-09-19 20:20:35 +00:00
puppet-fluentd/README.md

381 lines
8.1 KiB
Markdown
Raw Permalink Normal View History

2018-03-05 10:50:03 +00:00
# pilchkinstein-gtv/fluentd Puppet Module
2015-11-30 11:23:28 +00:00
2018-03-05 10:50:03 +00:00
[![GitHub version](https://badge.fury.io/gh/wywy%2Fpuppet-fluentd.svg)](https://github.com/pilchkinstein-gtv/puppet-fluentd)
2017-08-17 14:52:10 +00:00
[![Build Status](https://travis-ci.org/wywy/puppet-fluentd.svg?branch=master)](https://travis-ci.org/wywy/puppet-fluentd)
2015-12-07 11:34:35 +00:00
2015-12-07 17:51:12 +00:00
2015-11-30 11:23:28 +00:00
#### Table of Contents
1. [Description](#description)
1. [Setup - The basics of getting started with fluentd](#setup)
2015-12-01 16:18:07 +00:00
1. [Usage](#usage)
* [Configuration](#configuration)
2015-12-22 12:57:09 +00:00
* [Parameters](#parameters)
2015-12-01 16:18:07 +00:00
* [Source](#source)
* [Filter](#filter)
* [Match](#match)
* [Match with buffer and chunk_keys](#match-with-buffer-and-chunk_keys)
* [Match Store](#match-store)
2015-12-03 10:59:51 +00:00
* [Plugin Installation](#plugin-installation)
2015-12-01 16:18:07 +00:00
* [Requirements](#requirements)
2015-11-30 11:23:28 +00:00
1. [Limitations - OS compatibility, etc.](#limitations)
1. [Development - Guide for contributing to the module](#development)
2015-12-07 17:35:59 +00:00
1. [License](#license)
2015-11-30 11:23:28 +00:00
## Description
2015-12-01 16:18:07 +00:00
The fluentd module sets up fluentd (td-agent) and manages configuration files.
2015-11-30 11:23:28 +00:00
2015-12-01 16:18:07 +00:00
**This module only supports fluentd from version 2**.
2015-11-30 11:23:28 +00:00
## Setup
2015-12-01 16:18:07 +00:00
This will install the latest version of fluentd
2015-11-30 11:23:28 +00:00
2015-12-01 16:18:07 +00:00
```puppet
include '::fluentd'
```
2015-11-30 11:23:28 +00:00
## Usage
2015-12-01 16:18:07 +00:00
**By default this module doesn't configure any sources, matches or filters.** The section below describes how to configure these.
### Configuration
2015-12-01 16:21:31 +00:00
2015-12-22 12:57:09 +00:00
#### Parameters
`repo_manage`
2015-12-22 13:05:49 +00:00
Include repository to install recent fluentd (td-agent) from.
2015-12-22 12:57:09 +00:00
**Default:** 'true'
2017-08-14 11:18:06 +00:00
2015-12-22 12:57:09 +00:00
`package_ensure`
2015-12-22 13:05:49 +00:00
Package ensure.
2015-12-22 12:57:09 +00:00
**Default:** 'installed'
2017-08-14 11:18:06 +00:00
2015-12-22 12:57:09 +00:00
`package_name`
2015-12-22 13:05:49 +00:00
Package name.
2015-12-22 12:57:09 +00:00
**Default:** 'td-agent'
2017-08-14 11:18:06 +00:00
2015-12-22 12:57:09 +00:00
`package_install_options`
2015-12-22 13:05:49 +00:00
Package install options.
2015-12-22 12:57:09 +00:00
**Default:** '[]'
2017-08-14 11:18:06 +00:00
2015-12-22 12:57:09 +00:00
`service_manage`
2015-12-22 13:05:49 +00:00
Defines if the service should be managed by puppet.
2015-12-22 12:57:09 +00:00
**Default:** 'true'
2017-08-14 11:18:06 +00:00
2015-12-22 12:57:09 +00:00
`service_name`
2015-12-22 13:05:49 +00:00
Name of the service.
2015-12-22 12:57:09 +00:00
**Default:** 'td-agent'
2017-08-14 11:18:06 +00:00
2015-12-22 12:57:09 +00:00
`service_ensure`
2015-12-22 13:05:49 +00:00
Service ensure.
2015-12-22 12:57:09 +00:00
**Default:** 'running'
2017-08-14 11:18:06 +00:00
`service_enable`
2015-12-22 13:05:49 +00:00
Defines if the service should be enabled.
2015-12-22 12:57:09 +00:00
**Default:** 'true'
2017-08-14 11:18:06 +00:00
`config_path`
Path to configuration files
**Default:** '/etc/td-agent'
2017-08-14 11:18:06 +00:00
`config_dir`
Configuration directory name
**Default:** '${config_path}/conf.d'
`config_file`
Default configuration file name
**Default:** '${config_path}/td-agent.conf'
`conf_dir_manage`
Exclusively handle config files into fluentd::conf_dir. Other files not created by puppet, will be deleted
**Default:** 'false'
2015-12-22 12:57:09 +00:00
`user_manage`
2015-12-22 13:05:49 +00:00
2015-12-22 12:57:09 +00:00
Defines if the user should be manage, which will add the user
to groups defined in `user_groups`.
For example to be able to view the /var/log directory with group adm
**Default:** 'true'
2015-12-22 13:05:49 +00:00
2015-12-22 12:57:09 +00:00
`user_name`
2015-12-22 13:05:49 +00:00
2015-12-22 12:57:09 +00:00
**Default:** 'td-agent'
2017-08-14 11:18:06 +00:00
2015-12-22 12:57:09 +00:00
`user_group`
2015-12-22 13:05:49 +00:00
2015-12-22 12:57:09 +00:00
**Default:** 'td-agent'
2017-08-14 11:18:06 +00:00
2015-12-22 12:57:09 +00:00
`user_groups`
2015-12-22 13:05:49 +00:00
2015-12-22 12:57:09 +00:00
**Default:** '["adm"]'
2015-12-01 16:18:07 +00:00
#### Source
```puppet
::fluentd::source { 'test':
priority => 10,
config => {
2015-12-04 11:54:07 +00:00
'type' => 'tail',
'format' => 'json',
'path' => '/var/log/test-application/*.json',
'parse' => {
'type' => 'regexp',
'expression' => '^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$'
},
'storage'=> {
'type' => 'local',
'path' => 'test.pos'
},
'tag' => 'application.test',
'parse' => {
'message_format' => 'auto'
}
2015-12-01 16:18:07 +00:00
}
}
```
2015-12-07 10:20:51 +00:00
**creates:**
2015-12-01 16:18:07 +00:00
```
/etc/td-agent/conf.d/10-source-test.conf
<source>
2015-12-07 10:20:51 +00:00
type tail
format json
path /var/log/test-application/*.json
<parse>
type regexp
expression ^(?<name>[^ ]*) (?<user>[^ ]*) (?<age>\d*)$
</parse>
<storage>
type local
path test.pos
</storage>
2015-12-07 10:20:51 +00:00
tag application.test
<parse>
message_format auto
</parse>
2015-12-01 16:18:07 +00:00
</source>
```
#### Filter
```puppet
::fluentd::filter { 'test':
priority => 20,
2015-12-04 11:54:07 +00:00
pattern => '*.test',
2015-12-01 16:18:07 +00:00
config => {
2015-12-04 11:54:07 +00:00
'type' => 'record_transformer',
2015-12-01 16:18:07 +00:00
'record' => {
'hostname' => '${hostname}'
}
}
}
```
2015-12-07 10:20:51 +00:00
**creates:**
2015-12-01 16:18:07 +00:00
```
/etc/td-agent/conf.d/20-filter-test.conf
<filter *.test>
2015-12-07 10:20:51 +00:00
type record_transformer
<record>
hostname ${hostname}
</record>
2015-12-01 16:18:07 +00:00
</filter>
```
#### Match
```puppet
::fluentd::match { 'test':
priority => 30,
2015-12-04 11:54:07 +00:00
pattern => '*.test',
2015-12-01 16:18:07 +00:00
config => {
2015-12-04 11:54:07 +00:00
'flush_interval' => '30s',
'type' => 'secure_forward',
'secure' => 'yes',
'shared_key' => 'my_shared_key',
'self_hostname' => 'instance.test.com',
'ca_cert_path' => '/path/to/ca.cert',
'server' => [{
'host' => 'test.server.com',
}]
2015-12-01 16:18:07 +00:00
}
}
```
2015-12-07 10:20:51 +00:00
**creates:**
2015-12-01 16:18:07 +00:00
```
/etc/td-agent/conf.d/30-match-test.conf
<match *.test>
2015-12-07 10:20:51 +00:00
flush_interval 30s
type secure_forward
secure yes
shared_key my_shared_key
self_hostname instance.test.com
ca_cert_path /path/to/ca.cert
<server>
2015-12-07 10:20:51 +00:00
host test.server.com
</server>
</match>
```
#### Match with buffer and chunk_keys
buffer_chunk_keys will not be included in the template. They will be filtered and only be used as a "pattern" for the buffer section.
```
::fluentd::match { 'test':
priority => 98,
pattern => 'test.**',
config => {
type => 'file',
path => '/var/log/td-agent/test/${host}',
append => true,
buffer_chunk_keys => 'host',
buffer => {
type => file,
path => /var/log/td-agent/test/buffer/,
flush_mode => immediate,
},
},
}
```
**creates:**
```
<match test.**>
type file
path /var/log/td-agent/test/${host}
append true
<buffer host>
type file
path /var/log/td-agent/test/buffer/
flush_mode immediate
</buffer>
</match>
```
#### Match Store
```puppet
::fluentd::match { 'test':
priority => 30,
pattern => '*.test',
2016-01-27 17:25:36 +00:00
config => {
'type' => 'copy',
'store' => [
{
'type' => 'elasticsearch',
'logstashformat' => true,
'hosts' => '172.20.10.17:9200',
'flush_interval' => '30s',
},
{
'type' => 'file',
'path' => '/tmp/td-agent-debug-${host}.log',
'buffer_chunk_keys' => 'host',
'buffer' => [{
'@type' => 'file',
path => '/var/log/td-agent/buffer/',
flush_mode => 'immediate',
}]
}
]
}
}
```
**creates:**
```
/etc/td-agent/conf.d/30-match-test.conf
<match *.test>
type copy
<store>
type elasticsearch
logstash_format true
hosts 172.20.10.17:9200
flush_interval 30s
</store>
<store>
type file
path /tmp/td-agent-debug-${host}.log
<buffer host>
@type file
path /var/log/td-agent/buffer/
flush_mode immediate
</store>
2015-12-01 16:18:07 +00:00
</match>
```
2015-11-30 11:23:28 +00:00
2015-12-03 10:59:51 +00:00
### Plugin Installation
This module gives you the possibility to install plugins as gem or files.
**gem installation**
```puppet
::fluentd::plugin { 'fluent-plugin-elasticsearch':
type => 'gem',
ensure => '0.1.3'
2015-12-03 10:59:51 +00:00
}
```
**file installation**
```puppet
::fluentd::plugin { 'fluent-plugin-elasticsearch':
type => 'file',
source => 'puppet:///path/to/plugin'
}
```
2015-12-01 16:21:31 +00:00
### Requirements
Modules:
* puppetlabs/apt >= 4.0.0
2015-12-01 16:21:31 +00:00
2015-11-30 11:23:28 +00:00
## Limitations
This module has been built on and tested against Puppet 4.6 and higher.
2015-11-30 11:23:28 +00:00
2015-12-01 16:18:07 +00:00
The module has been tested on:
2015-11-30 11:23:28 +00:00
* Ubuntu 16.04
2015-11-30 11:23:28 +00:00
2015-12-01 16:18:07 +00:00
Testing on other platforms has been light and cannot be guaranteed.
2015-11-30 11:23:28 +00:00
2015-12-01 16:18:07 +00:00
## Development
2015-11-30 11:23:28 +00:00
### Running the test suite
To run the tests install the ruby dependencies with `bundler` and execute
`rake`:
```
bundle install --path vendor/bundle
2015-12-03 17:04:08 +00:00
bundle exec rake spec
bundle exec rake lint
2016-01-22 23:32:29 +00:00
bundle exec rake beaker BEAKER_set=ubuntu-server-1404-x64
bundle exec rake beaker BEAKER_set=ubuntu-server-1604-x64
2016-01-22 23:32:29 +00:00
bundle exec rake beaker BEAKER_set=debian-60-x64
bundle exec rake beaker BEAKER_set=debian-78-x64
bundle exec rake beaker BEAKER_set=debian-82-x64
2016-01-27 12:43:34 +00:00
bundle exec rake beaker BEAKER_set=centos-66-x64
bundle exec rake beaker BEAKER_set=centos-70-x64
```
2015-12-07 17:35:59 +00:00
## License
2017-08-17 15:10:15 +00:00
Copyright 2017 ATVAG GmbH
2015-12-07 17:35:59 +00:00
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
2017-08-10 12:24:22 +00:00
This Puppet module is being actively maintained by some fellow puppeteers at [wywy](http://wywy.com/).