Merge pull request #525 from enovance/fluentd_dynamic_sources
logging/agent.pp: provide greater flexibility for sources
This commit is contained in:
commit
da4bae48cf
@ -23,14 +23,23 @@
|
||||
# (optional) IP address or hostname of the logging server
|
||||
# Defaults to '127.0.0.1'
|
||||
#
|
||||
|
||||
# [*sources*]
|
||||
# (optional) Fluentd sources
|
||||
# Defaults to empty hash
|
||||
#
|
||||
class cloud::logging::agent(
|
||||
$server = '127.0.0.1'
|
||||
$server = '127.0.0.1',
|
||||
$sources = {},
|
||||
){
|
||||
|
||||
include cloud::logging
|
||||
|
||||
fluentd::configfile { 'syslog': }
|
||||
resources {'fluentd::configfile':
|
||||
purge => true,
|
||||
}
|
||||
resources {'fluentd::source' :
|
||||
purge => true,
|
||||
}
|
||||
|
||||
file { '/var/db':
|
||||
ensure => directory,
|
||||
@ -42,16 +51,8 @@ class cloud::logging::agent(
|
||||
require => Class['fluentd'],
|
||||
}
|
||||
|
||||
fluentd::source { 'syslog_main':
|
||||
configfile => 'syslog',
|
||||
type => 'tail',
|
||||
format => 'syslog',
|
||||
tag => 'system.syslog',
|
||||
config => {
|
||||
path => '/var/log/syslog',
|
||||
pos_file => '/var/db/td-agent/td-agent.syslog.pos'
|
||||
}
|
||||
}
|
||||
create_resources('fluentd::configfile', keys($sources))
|
||||
create_resources('fluentd::source', $sources)
|
||||
|
||||
fluentd::match { 'forward_main':
|
||||
configfile => 'forward',
|
||||
|
@ -27,13 +27,27 @@ describe 'cloud::logging::agent' do
|
||||
include ::fluentd"
|
||||
end
|
||||
|
||||
let :params do {
|
||||
:server => '127.0.0.1',
|
||||
:sources => {
|
||||
'apache' => {'type' => 'tail', 'configfile' => 'apache'},
|
||||
'syslog' => {'type' => 'tail', 'configfile' => 'syslog'}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
it 'configure logging common' do
|
||||
it should contain_concat("/etc/td-agent/config.d/forward.conf")
|
||||
end
|
||||
|
||||
it 'configure elasticsearch' do
|
||||
should contain_class('elasticsearch')
|
||||
it 'config apache logging source' do
|
||||
it should contain_fluentd__configfile('apache')
|
||||
it should contain_fluentd__source('apache').with({
|
||||
:type => 'tail',
|
||||
:configfile => 'apache',
|
||||
})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'on Debian platforms' do
|
||||
|
Loading…
x
Reference in New Issue
Block a user