Skip to content

Commit 0eeda3a

Browse files
authored
Merge pull request #197 from aaron-miller/topic_fluentd
Feature: Fluentd Integration
2 parents f97af0c + ff083b6 commit 0eeda3a

3 files changed

Lines changed: 103 additions & 0 deletions

File tree

manifests/integrations/fluentd.pp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Class: datadog_agent::integrations::fluentd
2+
#
3+
# This class will install the fluentd integration
4+
#
5+
# Parameters:
6+
# $monitor_agent_url
7+
# The url fluentd lists it's plugins on
8+
#
9+
# Sample Usage:
10+
#
11+
# class { 'datadog_agent::integrations::fluentd' :
12+
# monitor_agent_url => 'http://localhost:24220/api/plugins.json',
13+
# plugin_ids => [
14+
# 'elasticsearch_out',
15+
# 'rsyslog_in',
16+
# ],
17+
# }
18+
#
19+
#
20+
class datadog_agent::integrations::fluentd(
21+
$monitor_agent_url = 'http://localhost:24220/api/plugins.json',
22+
$plugin_ids = [],
23+
) inherits datadog_agent::params {
24+
include ::datadog_agent
25+
26+
validate_array($plugin_ids)
27+
28+
file { "${datadog_agent::params::conf_dir}/fluentd.yaml":
29+
ensure => file,
30+
owner => $datadog_agent::params::dd_user,
31+
group => $datadog_agent::params::dd_group,
32+
mode => '0600',
33+
content => template('datadog_agent/agent-conf.d/fluentd.yaml.erb'),
34+
require => Package[$datadog_agent::params::package_name],
35+
notify => Service[$datadog_agent::params::service_name],
36+
}
37+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
require 'spec_helper'
2+
3+
describe 'datadog_agent::integrations::fluentd' do
4+
let(:facts) {{
5+
operatingsystem: 'Ubuntu',
6+
}}
7+
let(:conf_dir) { '/etc/dd-agent/conf.d' }
8+
let(:dd_user) { 'dd-agent' }
9+
let(:dd_group) { 'root' }
10+
let(:dd_package) { 'datadog-agent' }
11+
let(:dd_service) { 'datadog-agent' }
12+
let(:conf_file) { "#{conf_dir}/fluentd.yaml" }
13+
14+
context 'with default parameters' do
15+
it { should compile }
16+
end
17+
18+
context 'with monitor_agent_url set' do
19+
let(:params) {{
20+
monitor_agent_url: 'foobar',
21+
}}
22+
23+
it { should compile.with_all_deps }
24+
it { should contain_file(conf_file).with(
25+
owner: dd_user,
26+
group: dd_group,
27+
mode: '0600',
28+
)}
29+
it { should contain_file(conf_file).that_requires("Package[#{dd_package}]") }
30+
it { should contain_file(conf_file).that_notifies("Service[#{dd_service}]") }
31+
32+
it { should contain_file(conf_file).with_content(%r{monitor_agent_url: foobar}) }
33+
it { should contain_file(conf_file).without_content(%r{tags: }) }
34+
35+
context 'with plugin_ids parameter array' do
36+
let(:params) {{
37+
monitor_agent_url: 'foobar',
38+
plugin_ids: %w{ foo bar baz },
39+
}}
40+
it { should contain_file(conf_file).with_content(/plugin_ids:[^-]+- foo\s+- bar\s+- baz\s*?[^-]/m) }
41+
end
42+
43+
context 'plugin_ids not array' do
44+
let(:params) {{
45+
monitor_agent_url: 'foobar',
46+
plugin_ids: 'aoeu',
47+
}}
48+
49+
it { should_not compile }
50+
end
51+
end
52+
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# MANAGED BY PUPPET
3+
#
4+
5+
init_config:
6+
7+
instances:
8+
- monitor_agent_url: <%= @monitor_agent_url %>
9+
<% if !@plugin_ids.empty? -%>
10+
plugin_ids:
11+
<% @plugin_ids.each do |plugin| -%>
12+
- <%= plugin %>
13+
<% end -%>
14+
<% end -%>

0 commit comments

Comments
 (0)