Skip to content

Commit 92db780

Browse files
committed
[service_discovery][dogstatsd] adding relevant SD and dogstatsd to the relevant fragments.
1 parent 9e64e1d commit 92db780

2 files changed

Lines changed: 67 additions & 14 deletions

File tree

spec/classes/datadog_agent_spec.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
'content' => /^# bind_host: localhost\n/,
124124
)}
125125
it { should contain_concat__fragment('datadog footer').with(
126-
'content' => /^use_dogstatsd: no\n/,
126+
'content' => /^use_dogstatsd: yes\n/,
127127
)}
128128
it { should contain_concat__fragment('datadog footer').with(
129129
'content' => /^dogstatsd_port: 8125\n/,
@@ -182,26 +182,26 @@
182182
end
183183

184184
context 'for service_discovery' do
185-
it { should contain_file('/etc/dd-agent/datadog.conf').without(
185+
it { should contain_concat__fragment('datadog footer').without(
186186
'content' => /^service_discovery_backend:\n/,
187187
)}
188-
it { should contain_file('/etc/dd-agent/datadog.conf').without(
188+
it { should contain_concat__fragment('datadog footer').without(
189189
'content' => /^sd_config_backend:\n/,
190190
)}
191-
it { should contain_file('/etc/dd-agent/datadog.conf').without(
191+
it { should contain_concat__fragment('datadog footer').without(
192192
'content' => /^sd_backend_host:\n/,
193193
)}
194-
it { should contain_file('/etc/dd-agent/datadog.conf').without(
194+
it { should contain_concat__fragment('datadog footer').without(
195195
'content' => /^sd_backend_port:\n/,
196196
)}
197-
it { should contain_file('/etc/dd-agent/datadog.conf').without(
197+
it { should contain_concat__fragment('datadog footer').without(
198198
'content' => /^sd_template_dir:\n/,
199199
)}
200-
it { should contain_file('/etc/dd-agent/datadog.conf').without(
200+
it { should contain_concat__fragment('datadog footer').without(
201201
'content' => /^consul_token:\n/,
202202
)}
203-
it { should contain_file('/etc/dd-agent/datadog.conf').with(
204-
'content' => /^# sd_jmx_enable: no\n/,
203+
it { should contain_concat__fragment('datadog footer').without(
204+
'content' => /^# sd_jmx_enable:\n/,
205205
)}
206206
end
207207

@@ -536,19 +536,19 @@
536536
:sd_backend_port => '8080',
537537
:sd_jmx_enable => true,
538538
}}
539-
it { should contain_file('/etc/dd-agent/datadog.conf').with(
539+
it { should contain_concat__fragment('datadog footer').with(
540540
'content' => /^service_discovery_backend: docker\n/,
541541
)}
542-
it { should contain_file('/etc/dd-agent/datadog.conf').with(
542+
it { should contain_concat__fragment('datadog footer').with(
543543
'content' => /^sd_config_backend: etcd\n/,
544544
)}
545-
it { should contain_file('/etc/dd-agent/datadog.conf').with(
545+
it { should contain_concat__fragment('datadog footer').with(
546546
'content' => /^sd_backend_host: localhost\n/,
547547
)}
548-
it { should contain_file('/etc/dd-agent/datadog.conf').with(
548+
it { should contain_concat__fragment('datadog footer').with(
549549
'content' => /^sd_backend_port: 8080\n/,
550550
)}
551-
it { should contain_file('/etc/dd-agent/datadog.conf').with(
551+
it { should contain_concat__fragment('datadog footer').with(
552552
'content' => /^sd_jmx_enable: true\n/,
553553
)}
554554
end

templates/datadog_footer.conf.erb

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,59 @@ syslog_host: <%= @syslog_host %>
290290
syslog_port: <%= @syslog_port %>
291291
<% end -%>
292292

293+
294+
# ========================================================================== #
295+
# Service Discovery
296+
# ========================================================================== #
297+
298+
# For now only docker is supported so you just need to un-comment this line.
299+
<% if @service_discovery_backend.empty? -%>
300+
# service_discovery_backend: docker
301+
<% else -%>
302+
service_discovery_backend: <%= @service_discovery_backend %>
303+
<% end -%>
304+
305+
# Define which key/value store must be used to look for configuration templates.
306+
# Default is etcd. Consul is also supported.
307+
<% if @sd_config_backend.empty? -%>
308+
# sd_config_backend: etcd
309+
<% else -%>
310+
sd_config_backend: <%= @sd_config_backend %>
311+
<% end -%>
312+
313+
# Settings for connecting to the backend. These are the default, edit them if you run a different config.
314+
<% if @sd_backend_host.empty? -%>
315+
# sd_backend_host: 127.0.0.1
316+
<% else -%>
317+
sd_backend_host: <%= @sd_backend_host %>
318+
<% end -%>
319+
<% if @sd_backend_port.to_i < 1 -%>
320+
# sd_backend_port: 4001
321+
<% else -%>
322+
sd_backend_port: <%= @sd_backend_port %>
323+
<% end -%>
324+
325+
# By default, the agent will look for the configuration templates under the
326+
# `/datadog/check_configs` key in the back-end.
327+
# If you wish otherwise, uncomment this option and modify its value.
328+
<% if @sd_template_dir.empty? -%>
329+
# sd_template_dir: /datadog/check_configs
330+
<% else -%>
331+
sd_template_dir: <%= @sd_template_dir %>
332+
<% end -%>
333+
334+
# Enable JMX checks for service discovery
335+
<% if @sd_jmx_enable -%>
336+
sd_jmx_enable: <%= @sd_jmx_enable %>
337+
<% end -%>
338+
339+
# If you Consul store requires token authentication for service discovery, you can define that token here.
340+
<% if @consul_token.empty? -%>
341+
# consul_token: f45cbd0b-5022-samp-le00-4eaa7c1f40f1
342+
<% else -%>
343+
consul_token: <%= @consul_token %>
344+
<% end -%>
345+
293346
<% if not @extra_template.empty? -%>
294347
# ========================================================================== #
295348
# Custom Templates from Puppet #

0 commit comments

Comments
 (0)