Skip to content

Commit 011cad9

Browse files
jadams-avtruthbk
authored andcommitted
Enable log collection for nginx integration (DataDog#519)
* Enable log collection for nginx integration Add optional log collection to the nginx integration * Fix value of path test * Update nginx_integration test Rename service to match example code Add nginx error log to match example code * Specify type of log variable * Fix data type syntax error
1 parent db0dd1e commit 011cad9

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

manifests/integrations/nginx.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#
2525
class datadog_agent::integrations::nginx(
2626
Array $instances = [],
27+
Optional[Array] $logs = undef,
2728
) inherits datadog_agent::params {
2829
include datadog_agent
2930

spec/classes/datadog_agent_integrations_nginx_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,33 @@
4343
'nginx_status_url' => 'http://foo.bar:1941/check',
4444
'tags' => %w{foo bar baz}
4545
}
46+
],
47+
logs: [
48+
{
49+
'type' => 'file',
50+
'path' => '/var/log/nginx/access.log',
51+
'service' => 'nginx',
52+
'source' => 'nginx',
53+
'sourcecategory' => 'http_web_access'
54+
},
55+
{
56+
'type' => 'file',
57+
'path' => '/var/log/nginx/error.log',
58+
'service' => 'nginx',
59+
'source' => 'nginx',
60+
'sourcecategory' => 'http_web_access'
61+
}
4662
]
4763
}}
4864

4965
it { should contain_file(conf_file).with_content(%r{nginx_status_url:.*http://foo.bar:1941/check}m) }
5066
it { should contain_file(conf_file).with_content(%r{tags:.*foo.*bar.*baz}m) }
67+
it { should contain_file(conf_file).with_content(%r{type:.*file}m) }
68+
it { should contain_file(conf_file).with_content(%r{path:.*/var/log/nginx/access.log}m) }
69+
it { should contain_file(conf_file).with_content(%r{service:.*nginx}m) }
70+
it { should contain_file(conf_file).with_content(%r{source:.*nginx}m) }
71+
it { should contain_file(conf_file).with_content(%r{sourcecategory:.*http_web_access}m) }
72+
it { should contain_file(conf_file).with_content(%r{path:.*/var/log/nginx/error.log}m) }
5173
end
5274
end
5375
end

templates/agent-conf.d/nginx.yaml.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,8 @@
1818
require 'yaml'
1919
%>
2020

21+
<% if @logs %>
22+
<%= {'init_config'=>nil, 'instances'=>@instances, 'logs'=>@logs}.to_yaml %>
23+
<% else %>
2124
<%= {'init_config'=>nil, 'instances'=>@instances}.to_yaml %>
25+
<% end %>

0 commit comments

Comments
 (0)