forked from DataDog/puppet-datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added logs configuration (DataDog#439)
- Loading branch information
1 parent
7ca91cb
commit 05cdd26
Showing
7 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Class: datadog_agent::integrations::logs | ||
# | ||
# This class will install the necessary configuration for the logs integration. | ||
# | ||
# Parameters: | ||
# $logs: | ||
# array of log sources. | ||
# | ||
# Log Source: | ||
# $type | ||
# Type of log input source (tcp / udp / file / docker / journald / windows_event). | ||
# $service | ||
# Optional name of the service owning the log. | ||
# $source | ||
# Optional attribute that defines which integration is sending the logs. | ||
# $tags | ||
# Optional tags that are added to each log collected. | ||
# $log_processing_rules | ||
# Optional array of processing rules. | ||
# | ||
# Sample Usage: | ||
# | ||
# class { 'datadog_agent::integrations::logs' : | ||
# logs => [ | ||
# { | ||
# 'type' => 'file', | ||
# 'path' => '/var/log/afile.log', | ||
# }, | ||
# { | ||
# 'type' => 'docker', | ||
# }, | ||
# ], | ||
# } | ||
# | ||
# Documentation: | ||
# https://docs.datadoghq.com/logs/log_collection | ||
# | ||
|
||
class datadog_agent::integrations::logs( | ||
Array $logs = [], | ||
) inherits datadog_agent::params { | ||
unless $::datadog_agent::agent5_enable { | ||
include datadog_agent | ||
validate_legacy('Array', 'validate_array', $logs) | ||
|
||
file { "${datadog_agent::conf6_dir}/logs.yaml": | ||
ensure => file, | ||
owner => $datadog_agent::params::dd_user, | ||
group => $datadog_agent::params::dd_group, | ||
mode => '0600', | ||
content => template('datadog_agent/agent-conf.d/logs.yaml.erb'), | ||
require => Package[$datadog_agent::params::package_name], | ||
notify => Service[$datadog_agent::params::service_name] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'spec_helper' | ||
|
||
describe 'datadog_agent::integrations::logs' do | ||
context 'supported agents - v6' do | ||
let(:pre_condition) { "class {'::datadog_agent': agent5_enable => false}" } | ||
let(:facts) {{ | ||
operatingsystem: 'Ubuntu', | ||
}} | ||
let(:conf_dir) { '/etc/datadog-agent/conf.d' } | ||
let(:dd_user) { 'dd-agent' } | ||
let(:dd_group) { 'root' } | ||
let(:dd_package) { 'datadog-agent' } | ||
let(:dd_service) { 'datadog-agent' } | ||
let(:conf_file) { "#{conf_dir}/logs.yaml" } | ||
|
||
context 'with default parameters' do | ||
it { should compile } | ||
end | ||
|
||
context 'with parameters set' do | ||
let(:params) {{ | ||
logs: [ | ||
{ | ||
'type' => 'file', | ||
'path' => 'apath.log', | ||
}, | ||
{ | ||
'type' => 'docker', | ||
}, | ||
], | ||
}} | ||
it { should contain_file(conf_file).with_content(%r{logs:}) } | ||
it { should contain_file(conf_file).with_content(%r{- type: file}) } | ||
it { should contain_file(conf_file).with_content(%r{path: apath.log}) } | ||
it { should contain_file(conf_file).with_content(%r{- type: docker}) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<% | ||
require 'yaml' | ||
%> | ||
|
||
<%= {'logs'=>@logs}.to_yaml %> |