Skip to content

Commit 8dfc579

Browse files
authored
Merge pull request #204 from vend/improve-consul-support
More configuration options for Consul checks
2 parents a0ff7d3 + 447d5dc commit 8dfc579

2 files changed

Lines changed: 34 additions & 4 deletions

File tree

manifests/integrations/consul.pp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,39 @@
55
# Parameters:
66
# $url:
77
# The URL for consul
8+
# $catalog_checks:
9+
# Whether to perform checks against the Consul service Catalog
10+
# Optional.
11+
# $new_leader_checks:
12+
# Whether to enable new leader checks from this agent
13+
# Note: if this is set on multiple agents in the same cluster
14+
# you will receive one event per leader change per agent
15+
# $service_whitelist
16+
# Services to restrict catalog querying to
17+
# The default settings query up to 50 services. So if you have more than
18+
# this many in your Consul service catalog, you will want to fill in the
19+
# whitelist
820
#
921
# Sample Usage:
1022
#
1123
# class { 'datadog_agent::integrations::consul' :
1224
# url => "http://localhost:8500"
25+
# catalog_checks => true,
26+
# new_leader_checks => false,
1327
# }
1428
#
1529
class datadog_agent::integrations::consul(
16-
$url = 'http://localhost:8500'
30+
$url = 'http://localhost:8500',
31+
$catalog_checks = true,
32+
$new_leader_checks = true,
33+
$service_whitelist = []
1734
) inherits datadog_agent::params {
1835

36+
validate_string($url)
37+
validate_bool($catalog_checks)
38+
validate_bool($new_leader_checks)
39+
validate_array($service_whitelist)
40+
1941
file { "${datadog_agent::params::conf_dir}/consul.yaml":
2042
ensure => file,
2143
owner => $datadog_agent::params::dd_user,

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ instances:
2222
# ca_bundle_file: '/path/to/trusted_ca_bundle_file'
2323

2424
# Whether to perform checks against the Consul service Catalog
25-
catalog_checks: yes
25+
catalog_checks: <%= @catalog_checks ? 'yes' : 'no' %>
2626

2727
# Whether to enable new leader checks from this agent
2828
# Note: if this is set on multiple agents in the same cluster
2929
# you will receive one event per leader change per agent
30-
new_leader_checks: yes
30+
new_leader_checks: <%= @new_leader_checks ? 'yes' : 'no' %>
3131

3232
# Services to restrict catalog querying to
3333
# The default settings query up to 50 services. So if you have more than
@@ -36,4 +36,12 @@ instances:
3636
# service_whitelist:
3737
# - zookeeper
3838
# - gunicorn
39-
# - redis
39+
# - redis
40+
<% if @service_whitelist and ! @service_whitelist.empty? -%>
41+
service_whitelist:
42+
<%- Array(@service_whitelist).each do |svc| -%>
43+
<%- if svc != '' -%>
44+
- <%= svc %>
45+
<%- end -%>
46+
<%- end -%>
47+
<% end -%>

0 commit comments

Comments
 (0)