diff --git a/manifests/init.pp b/manifests/init.pp index 02b8bfb7..eea2da3d 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -6,6 +6,10 @@ # $dd_url: # The host of the Datadog intake server to send agent data to. # Defaults to https://app.datadoghq.com. +# $datadog_site: +# The site of the Datadog intake to send Agent data to. Defaults to 'datadoghq.com', +# set to 'datadoghq.eu' to send data to the EU site. +# This option is only available with agent version >= 6.6.0. # $host: # $api_key: # Your DataDog API Key. Please replace with your key value. @@ -203,7 +207,8 @@ # # class datadog_agent( - $dd_url = 'https://app.datadoghq.com', + $dd_url = '', + $datadog_site = $datadog_agent::params::datadog_site, $host = '', $api_key = 'your_API_key', $collect_ec2_tags = false, @@ -308,6 +313,7 @@ # lint:endignore validate_legacy(String, 'validate_string', $dd_url) + validate_legacy(String, 'validate_string', $datadog_site) validate_legacy(String, 'validate_string', $host) validate_legacy(String, 'validate_string', $api_key) validate_legacy(Array, 'validate_array', $tags) @@ -502,6 +508,11 @@ require => File['/etc/dd-agent'], } + if ($dd_url == '') { + $_dd_url = 'https://app.datadoghq.com' + } else { + $_dd_url = $dd_url + } concat::fragment{ 'datadog header': target => '/etc/dd-agent/datadog.conf', content => template('datadog_agent/datadog_header.conf.erb'), @@ -623,6 +634,7 @@ $_agent_config = { 'api_key' => $api_key, 'dd_url' => $dd_url, + 'site' => $datadog_site, 'cmd_port' => $cmd_port, 'collect_ec2_tags' => $collect_ec2_tags, 'conf_path' => $datadog_agent::params::conf6_dir, diff --git a/manifests/params.pp b/manifests/params.pp index 3b0ad40e..6d659604 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -15,6 +15,7 @@ # Sample Usage: # class datadog_agent::params { + $datadog_site = 'datadoghq.com' $agent5_enable = false $conf_dir = '/etc/dd-agent/conf.d' $conf6_dir = '/etc/datadog-agent/conf.d' diff --git a/spec/classes/datadog_agent_spec.rb b/spec/classes/datadog_agent_spec.rb index 8e0c8d05..b5e4b19a 100644 --- a/spec/classes/datadog_agent_spec.rb +++ b/spec/classes/datadog_agent_spec.rb @@ -894,7 +894,10 @@ 'content' => /^collect_ec2_tags: false\n/, )} it { should contain_file('/etc/datadog-agent/datadog.yaml').with( - 'content' => /^dd_url: \"{0,1}https:\/\/app.datadoghq.com\"{0,1}\n/, + 'content' => /^dd_url: ''\n/, + )} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^site: datadoghq.com\n/, )} it { should contain_file('/etc/datadog-agent/datadog.yaml').with( 'content' => /^enable_metadata_collection: true\n/, @@ -960,6 +963,14 @@ 'content' => /^collect_ec2_tags: true\n/, )} end + context 'datadog EU' do + let(:params) {{ + :datadog_site => 'datadoghq.eu', + }} + it { should contain_file('/etc/datadog-agent/datadog.yaml').with( + 'content' => /^site: datadoghq.eu\n/, + )} + end context 'forward statsd settings set' do let(:params) {{ :statsd_forward_host => 'foo', diff --git a/templates/datadog_header.conf.erb b/templates/datadog_header.conf.erb index 3f40fd44..1b7a4783 100644 --- a/templates/datadog_header.conf.erb +++ b/templates/datadog_header.conf.erb @@ -4,7 +4,7 @@ [Main] # The host of the Datadog intake server to send agent data to -dd_url: <%= @dd_url %> +dd_url: <%= @_dd_url %> # If you need a proxy to connect to the Internet, provide the settings here <% if @proxy_host.empty? -%>