Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 'log_level' class variable to manipulate agent's log levels. #32

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
# $non_local_traffic
# Enable you to use the agent as a proxy. Defaults to false.
# See https://github.com/DataDog/dd-agent/wiki/Proxy-Configuration
# $log_level
# Set value of 'log_level' variable. Default is 'info' as in dd-agent.
# Valid values here are: critical, debug, error, fatal, info, warn and warning.
#
# Actions:
#
Expand All @@ -45,7 +48,8 @@
$tags = [],
$puppet_run_reports = false,
$puppetmaster_user = 'puppet',
$non_local_traffic = false
$non_local_traffic = false,
$log_level = 'info'
) inherits datadog::params {

validate_string($dd_url)
Expand All @@ -55,6 +59,18 @@
validate_bool($puppet_run_reports)
validate_string($puppetmaster_user)
validate_bool($non_local_traffic)
validate_string($log_level)

case upcase($log_level) {
'CRITICAL': { $_loglevel = 'CRITICAL' }
'DEBUG': { $_loglevel = 'DEBUG' }
'ERROR': { $_loglevel = 'ERROR' }
'FATAL': { $_loglevel = 'FATAL' }
'INFO': { $_loglevel = 'INFO' }
'WARN': { $_loglevel = 'WARN' }
'WARNING': { $_loglevel = 'WARNING' }
default: { $_loglevel = 'INFO' }
}

include datadog::params

Expand Down
20 changes: 10 additions & 10 deletions templates/datadog.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#
[Main]

# The host of the Datadog intake server to send agent data to
dd_url: <%= dd_url %>
# The host of the Datadog intake server to send agent data to
dd_url: <%= @dd_url %>

# If you need a proxy to connect to the Internet, provide the settings here
# proxy_host: my-proxy.com
Expand All @@ -18,27 +18,27 @@ dd_url: <%= dd_url %>
# The Datadog api key to associate your Agent's data with your organization.
# Can be found here:
# https://app.datadoghq.com/account/settings
api_key: <%= api_key %>
api_key: <%= @api_key %>

# Force the hostname to whatever you want.
<% if host.empty? -%>
<% if @host.empty? -%>
# hostname:
<% else -%>
hostname: <%= host %>
hostname: <%= @host %>
<% end -%>

# Set the host's tags
#tags: mytag0, mytag1
<% if !tags.empty? -%>
tags: <%= tags.join(', ') %>
<% if !@tags.empty? -%>
tags: <%= @tags.join(', ') %>
<% end -%>


# Collect AWS EC2 custom tags as agent tags
# collect_ec2_tags: no

# Collect instance metadata
# The Agent will try to collect instance metadata for EC2 and GCE instances by
# The Agent will try to collect instance metadata for EC2 and GCE instances by
# trying to connect to the local endpoint: http://169.254.169.254
# See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html
# and https://developers.google.com/compute/docs/metadata
Expand Down Expand Up @@ -67,7 +67,7 @@ use_mount: no
# that might not have an internet connection
# For more information, please see
# https://github.com/DataDog/dd-agent/wiki/Network-Traffic-and-Proxy-Configuration
non_local_traffic: <%= non_local_traffic %>
non_local_traffic: <%= @non_local_traffic %>

# Select the Tornado HTTP Client in the forwarder
# Default to the simple http client
Expand Down Expand Up @@ -196,7 +196,7 @@ non_local_traffic: <%= non_local_traffic %>
# Logging
# ========================================================================== #

# log_level: INFO
log_level: <%= @_loglevel %>

# collector_log_file: /var/log/datadog/collector.log
# forwarder_log_file: /var/log/datadog/forwarder.log
Expand Down