# Generated by Chef, local modifications will be overwritten

[Main]
dd_url: <%= @dd_urls.join(',') %>
api_key: <%= @api_keys.join(',') %>
check_freq: <%= node['datadog']['check_freq'] %>
hostname: <%= node['datadog']['hostname'] %>
use_mount: <%= node['datadog']['use_mount'] ? "yes" : "no"  %>
listen_port: <%= node['datadog']['agent_port'] %>
bind_host: <%= node['datadog']['bind_host'] %>
<% if node['datadog']['autorestart'] -%>
autorestart: <%= node['datadog']['autorestart'] %>
<% end -%>
<% if node['datadog']['web_proxy']['skip_ssl_validation'] -%>
skip_ssl_validation: <%= node['datadog']['web_proxy']['skip_ssl_validation'] %>
<% end -%>
<% if node['datadog']['developer_mode'] -%>
developer_mode: <%= node['datadog']['developer_mode'] %>
<% end -%>

<% if node['datadog']['tags'].respond_to?(:each_pair) -%>
tags: <%= node['datadog']['tags'].reject{ |_k,v| v.empty? }.map{ |k,v| "#{k}:#{v}" }.join(',') %>
<% else -%>
tags: <%= node['datadog']['tags'] %>
<% end -%>
<% if node['datadog']['create_dd_check_tags'] -%>
create_dd_check_tags: <%= node['datadog']['create_dd_check_tags'] %>
<% end -%>
<% if node['datadog']['collect_ec2_tags'] -%>
collect_ec2_tags: <%= node['datadog']['collect_ec2_tags'] %>
<% end -%>

<% if node['datadog']['web_proxy']['host'] -%>
proxy_host: <%= node['datadog']['web_proxy']['host'] %>
proxy_port: <%= node['datadog']['web_proxy']['port'] %>
proxy_user: <%= node['datadog']['web_proxy']['user'] %>
proxy_password: <%= node['datadog']['web_proxy']['password'] %>
<% end -%>

<% if node['datadog']['non_local_traffic'] == true %>
non_local_traffic: true
<% end -%>

<% if !node['datadog']['dogstreams'].empty? -%>
dogstreams: <%= node['datadog']['dogstreams'].join(', ') %>
<% end -%>

<% if !node['datadog']['custom_emitters'].empty? -%>
custom_emitters: <%= node['datadog']['custom_emitters'].join(', ') %>
<% end -%>

<% if node['datadog']['agent_checks_interval'] -%>
agent_checks_interval: <%= node['datadog']['agent_checks_interval'] %>
<% end -%>

<% if node['datadog']['graphite'] -%>
graphite_listen_port: <%= node['datadog']['graphite_port'] %>
<% end -%>

## Histogram settings
histogram_aggregates: <%= node['datadog']['histogram_aggregates'] %>
histogram_percentiles: <%= node['datadog']['histogram_percentiles'] %>

<% if node['datadog']['dogstatsd'] -%>
# ========================================================================== #
# DogStatsd configuration                                                    #
# ========================================================================== #

# DogStatsd is a small server that aggregates your custom app metrics. For
# usage information, check out http://docs.datadoghq.com

#  Make sure your client is sending to the same port.
dogstatsd_port: <%= node['datadog']['dogstatsd_port'] %>

## The dogstatsd flush period.
dogstatsd_interval: <%= node['datadog']['dogstatsd_interval'] %>

## The target location to send the data
dogstatsd_target: <%= node['datadog']['dogstatsd_target'] %>

## If 'yes', counters and rates will be normalized to 1 second (that is divided
## by the dogstatsd_interval) before being sent to the server. Defaults to 'yes'
dogstatsd_normalize: <%= node['datadog']['dogstatsd_normalize'] %>
<% if node['datadog']['statsd_forward_host'] -%>
statsd_forward_host: <%= node['datadog']['statsd_forward_host'] %>
statsd_forward_port: <%= node['datadog']['statsd_forward_port'] %>
<% end -%>

<% if node['datadog']['statsd_metric_namespace'] -%>
statsd_metric_namespace: <%= node['datadog']['statsd_metric_namespace'] %>
<% end -%>
<% else -%>
use_dogstatsd: no
<% end -%>

# ========================================================================== #
# Logging
# ========================================================================== #

log_level: <%= node['datadog']['log_level'] %>

collector_log_file: <%= node['datadog']['log_file_directory'] %>/collector.log
forwarder_log_file: <%= node['datadog']['log_file_directory'] %>/forwarder.log
dogstatsd_log_file: <%= node['datadog']['log_file_directory'] %>/dogstatsd.log
jmxfetch_log_file: <%= node['datadog']['log_file_directory'] %>/jmxfetch.log
<% unless node['platform_family'] == 'windows' -%>
go-metro_log_file: <%= node['datadog']['log_file_directory'] %>/go-metro.log
<% end -%>

# if syslog is enabled but a host and port are not set, a local domain socket
# connection will be attempted
#
log_to_syslog: <%= node['datadog']['syslog']['active'] ? 'yes' : 'no' %>
<% if node['datadog']['syslog']['udp'] -%>
syslog_host: <%= node['datadog']['syslog']['host'] %>
syslog_port: <%= node['datadog']['syslog']['port'] %>

<% end -%>
# ========================================================================== #
# Legacy Integrations
# ========================================================================== #

# For integrations which do not yet use the yaml configurations
<%
if node['datadog']['legacy_integrations']
  node['datadog']['legacy_integrations'].each do |int_name, int_hash|
    if int_hash["enabled"] and int_hash.has_key? "config"
      description = int_name
      description += " - #{int_hash["description"]}" if int_hash["description"]
      description.gsub!(/^/, '# ')
-%>
<%= description %>
<%
      int_hash['config'].each do |k,v|
-%>
<%= k %>: <%= v %>
<%
      end
    end
  end
end
-%>

<% if ! node['datadog']['extra_config'].empty? -%>
# ========================================================================== #
# Other config options
# ========================================================================== #
  <% node['datadog']['extra_config'].each do |k, v| -%>
    <% if ! v.nil? -%>
<%= k %>: <%= v %>
    <% end -%>
  <% end -%>
<% end -%>

<% if node['datadog']['enable_trace_agent'] == true -%>
## Trace settings
apm_enabled: true

[trace.sampler]
extra_sample_rate: <%= node['datadog']['extra_sample_rate'] %>
max_traces_per_second: <%= node['datadog']['max_traces_per_second'] %>

[trace.receiver]
receiver_port: <%= node['datadog']['receiver_port'] %>
connection_limit: <%= node['datadog']['connection_limit'] %>
<% end -%>
