Skip to content
Merged
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
33 changes: 32 additions & 1 deletion manifests/integrations/docker_daemon.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,40 @@
# }
#
class datadog_agent::integrations::docker_daemon(
$group = 'docker',
$docker_root = '/',
$timeout = 10,
$api_version = 'auto',
$tls = false,
$tls_client_cert = '/path/to/client-cert.pem',
$tls_client_key = '/path/to/client-key.pem',
$tls_cacert = '/path/to/ca.pem',
$tls_verify = true,
$init_retry_interval = 0,
$init_retries = 0,
$url = 'unix://var/run/docker.sock',
$collect_events = true,
$filtered_event_types = [],
$collect_container_size = false,
$custom_cgroups = false,
$health_service_check_whitelist = [],
$collect_container_count = false,
$collect_volume_count = false,
$collect_images_stats = false,
$collect_image_size = false,
$collect_disk_stats = false,
$collect_exit_codes = false,
$exclude = [],
$include = [],
$tags = [],
$group = 'docker',
$ecs_tags = true,
# Possible values: "container_name", "image_name", "image_tag", "docker_image"
$performance_tags = [],
# Possible values: "image_name", "image_tag", "docker_image"
$container_tags = [],
# Ex. "com.docker.compose.service", "com.docker.compose.project"
$collect_labels_as_tags = [],
$event_attributes_as_tags = [],
) inherits datadog_agent::params {
include datadog_agent

Expand Down
8 changes: 4 additions & 4 deletions spec/classes/datadog_agent_integrations_docker_daemon_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
let(:params) {{
tags: %w{ foo bar baz },
}}
it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- bar\s+- baz\s*?[^-]/m) }
it { should contain_file(conf_file).with_content(%r{tags: \["foo", "bar", "baz"\]}) }
end

context 'with tags parameter with an empty tag' do
Expand All @@ -59,23 +59,23 @@
tags: [ 'foo', '', 'baz' ]
}}

it { should contain_file(conf_file).with_content(/tags:\s+- foo\s+- baz\s*?[^-]/m) }
it { should contain_file(conf_file).with_content(%r{tags: \["foo", "baz"\]}) }
end

context 'single element array of an empty string' do
let(:params) {{
tags: [''],
}}

skip("undefined behavior")
it { should contain_file(conf_file).with_content(%r{tags: \[\]}) }
end

context 'single value empty string' do
let(:params) {{
tags: '',
}}

skip("doubly undefined behavior")
it { should contain_file(conf_file).with_content(%r{tags: \[\]}) }
end
end
end
Expand Down
114 changes: 87 additions & 27 deletions templates/agent-conf.d/docker_daemon.yaml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,39 @@ init_config:
# Change the root directory to look at to get cgroup statistics. Useful when running inside a
# container with host directories mounted on a different folder. Default: /.
# Example for the docker-dd-agent container:
# docker_root: /host
docker_root: <%= @docker_root %>

# Timeout in seconds for the connection to the docker daemon
# Default: 5 seconds
#
# timeout: 10
timeout: <%= @timeout %>

# The version of the API the client will use. Specify 'auto' to use the API version provided by the server.
# api_version: auto
api_version: <%= @api_version %>

# Use TLS encryption while communicating with the Docker API
#
# tls: False
# tls_client_cert: /path/to/client-cert.pem
# tls_client_key: /path/to/client-key.pem
# tls_cacert: /path/to/ca.pem
# tls_verify: True
tls: <%= @tls %>
tls_client_cert: <%= @tls_client_cert %>
tls_client_key: <%= @tls_client_key %>
tls_cacert: <%= @tls_cacert %>
tls_verify: <%= @tls_verify %>

# Initialization retries
#
# if the agent is expected to start before Docker,
# use these settings to configure the retry policy.

# init_retry_interval defines how long (in seconds) the docker client
# will wait before retrying initialization.
# Defaults to 0.
#
init_retry_interval: <%= @init_retry_interval %>

# init_retries configures how many retries are made before failing permanently.
# Defaults to 0.
#
init_retries: <%= @init_retries %>

instances:
- ## Daemon and system configuration
Expand All @@ -35,29 +51,76 @@ instances:
# Create events whenever a container status change.
# Defaults to true.
#
# collect_events: false
collect_events: <%= @collect_events %>

# By default we do not collect events with a status ['top', 'exec_start', 'exec_create'].
# Here can be added additional statuses to be filtered.
# List of available statuses can be found here https://docs.docker.com/engine/reference/commandline/events/#object-types
filtered_event_types: [<%= @filtered_event_types && !@filtered_event_types.empty? ? '"' + @filtered_event_types.reject(&:empty?).join('", "') + '"' : nil %>]

# Collect disk usage per container with docker.container.size_rw and
# docker.container.size_rootfs metrics.
# Warning: This might take time for Docker daemon to generate,
# ensure that `docker ps -a -q` run fast before enabling it.
# Defaults to false.
#
# collect_container_size: false
collect_container_size: <%= @collect_container_size %>

# Do you use custom cgroups for this particular instance?
# Note: enabling this option modifies the way in which we inspect the containers and causes
# some overhead - if you run a high volume of containers we may timeout.
#
custom_cgroups: <%= @custom_cgroups %>

# Report docker container healthcheck events as service checks
# Note: enabling this option modifies the way in which we inspect the containers and causes
# some overhead - if you run a high volume of containers we may timeout.
# Container Healthchecks are available starting with docker 1.12, enabling with older
# versions will result in an UNKNOWN state for the service check.
#
# You must whitelist the containers you wish to submit health service checks for.
# Use the same mechanism as the tagging system (see Tag:performance_tags section).
# Example: ["docker_image:tomcat", "container_name:web_front_nginx"]
#
health_service_check_whitelist: [<%= @health_service_check_whitelist && !@health_service_check_whitelist.empty? ? '"' + @health_service_check_whitelist.reject(&:empty?).join('", "') + '"' : nil %>]

# Collect the container count tagged by state (running, paused, exited, dead)
# Defaults to false.
#
collect_container_count: <%= @collect_container_count %>

# Collect the volume count for attached and dangling volumes.
# Defaults to false.
#
collect_volume_count: <%= @collect_volume_count %>

# Collect images stats
# Number of available active images and intermediate images as gauges.
# Defaults to false.
#
# collect_images_stats: false
collect_images_stats: <%= @collect_images_stats %>

# Collect disk usage per image with docker.image.size and docker.image.virtual_size metrics.
# The check gets this size with the `docker images` command.
# Requires collect_images_stats to be enabled.
# Defaults to false.
#
# collect_image_size: false
collect_image_size: <%= @collect_image_size %>

# Collect disk metrics (total, used, free) through the docker info command for data and metadata.
# This is useful when these values can't be obtained by the disk check.
# Example: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-optimized_AMI.html
# Note that it only works when the storage driver is devicemapper.
# Explanation of these metrics can be found here:
# https://github.com/docker/docker/blob/v1.11.1/daemon/graphdriver/devmapper/README.md
# Defaults to false.
#
collect_disk_stats: <%= @collect_disk_stats %>

# Collect containers exit codes and send service checks critical when exit code is not 0
# Defaults to false.
#
collect_exit_codes: <%= @collect_exit_codes %>

# Exclude containers based on their tags
# An excluded container will be completely ignored. The rule is a regex on the tags.
Expand All @@ -75,28 +138,20 @@ instances:
#
# Default: include all containers


exclude: [<%= @exclude && !@exclude.empty? ? '"' + @exclude.reject(&:empty?).join('", "') + '"' : nil %>]
include: [<%= @include && !@include.empty? ? '"' + @include.reject(&:empty?).join('", "') + '"' : nil %>]

## Tagging
##
<% if @tags and ! @tags.empty? -%>
tags:
<%- Array(@tags).each do |tag| -%>
<%- if tag != '' -%>
- <%= tag %>
<%- end -%>
<%- end -%>
<% end -%>

# You can add extra tags to your Docker metrics with the tags list option.
# Example: ["extra_tag", "env:testing"]
#
# tags: []
tags: [<%= @tags && !@tags.empty? ? '"' + @tags.reject(&:empty?).join('", "') + '"' : nil %>]

# If the agent is running in an Amazon ECS task, tags container metrics with the ECS task name and version.
# Default: true
#
# ecs_tags: false
ecs_tags: <%= @ecs_tags %>

# Custom metrics tagging
# Define which Docker tags to apply on metrics.
Expand All @@ -110,14 +165,19 @@ instances:
# - container_name: Name of the container (example: "boring_euclid")
# - container_command: Command ran by the container (example: "echo 1")
#
# performance_tags: ["container_name", image_name", "image_tag", "docker_image"]
performance_tags: [<%= @performance_tags && !@performance_tags.empty? ? '"' + @performance_tags.reject(&:empty?).join('", "') + '"' : nil %>]

# Tags for containers count metrics.
# Available: ["image_name", "image_tag", "docker_image", "container_command"]
#
# container_tags: ["image_name", "image_tag", "docker_image"]
container_tags: [<%= @container_tags && !@container_tags.empty? ? '"' + @container_tags.reject(&:empty?).join('", "') + '"' : nil %>]

# List of container label names that should be collected and sent as tags.
# Default to None
# Example:
# collect_labels_as_tags: ["com.docker.compose.service", "com.docker.compose.project"]
collect_labels_as_tags: [<%= @collect_labels_as_tags && !@collect_labels_as_tags.empty? ? '"' + @collect_labels_as_tags.reject(&:empty?).join('", "') + '"' : nil %>]

# List of docker event attributes to add as tags of the datadog events
# Defaults to None.
#
event_attributes_as_tags: [<%= @event_attributes_as_tags && !@event_attributes_as_tags.empty? ? '"' + @event_attributes_as_tags.reject(&:empty?).join('", "') + '"' : nil %>]