From e5e9b8a91840c5558a051bd384212836ae95d22a Mon Sep 17 00:00:00 2001 From: Alan Scherger Date: Tue, 5 Apr 2016 10:02:52 -0500 Subject: [PATCH] fix mesos with new checks add dd user to docker group update to use docker_daemon add consul allow repo to be optionally managed use_mount is now managed in disk.yaml --- manifests/init.pp | 3 - .../{docker.pp => docker_daemon.pp} | 20 ++- .../{mesos.pp => mesos_master.pp} | 12 +- manifests/integrations/mesos_slave.pp | 29 +++++ manifests/redhat.pp | 6 +- templates/agent-conf.d/docker.yaml.erb | 17 --- templates/agent-conf.d/docker_daemon.yaml.erb | 115 ++++++++++++++++++ .../{mesos.yaml.erb => mesos_master.yaml.erb} | 6 +- templates/agent-conf.d/mesos_slave.yaml.erb | 7 ++ templates/datadog.conf.erb | 3 - 10 files changed, 182 insertions(+), 36 deletions(-) rename manifests/integrations/{docker.pp => docker_daemon.pp} (56%) rename manifests/integrations/{mesos.pp => mesos_master.pp} (69%) create mode 100644 manifests/integrations/mesos_slave.pp delete mode 100644 templates/agent-conf.d/docker.yaml.erb create mode 100644 templates/agent-conf.d/docker_daemon.yaml.erb rename templates/agent-conf.d/{mesos.yaml.erb => mesos_master.yaml.erb} (58%) create mode 100644 templates/agent-conf.d/mesos_slave.yaml.erb diff --git a/manifests/init.pp b/manifests/init.pp index a626cc2e..3f51ad75 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -42,9 +42,6 @@ # $log_to_syslog # Set value of 'log_to_syslog' variable. Default is true -> yes as in dd-agent. # Valid values here are: true or false. -# $use_mount -# Allow overriding default of tracking disks by device path instead of mountpoint -# Valid values here are: true or false. # $dogstatsd_port # Set value of the 'dogstatsd_port' variable. Defaultis 8125. # $statsd_forward_host diff --git a/manifests/integrations/docker.pp b/manifests/integrations/docker_daemon.pp similarity index 56% rename from manifests/integrations/docker.pp rename to manifests/integrations/docker_daemon.pp index 57ac2443..7d05812c 100644 --- a/manifests/integrations/docker.pp +++ b/manifests/integrations/docker_daemon.pp @@ -12,6 +12,10 @@ # $tags: # optional array of tags # +# $group: +# optional name of docker group to add dd-agent user too +# +# # Sample Usage: # # class { 'datadog_agent::integrations::docker' : @@ -19,18 +23,30 @@ # url => 'unix://var/run/docker.sock', # } # -class datadog_agent::integrations::docker( +class datadog_agent::integrations::docker_daemon( $new_tag_names = true, $url = 'unix://var/run/docker.sock', $tags = [], + $group = 'docker', ) inherits datadog_agent::params { + exec { 'dd-agent-should-be-in-docker-group': + command => "/usr/sbin/usermod -aG ${group} ${datadog_agent::params::dd_user}", + unless => "/bin/cat /etc/group | grep '^${group}:' | grep -qw ${datadog_agent::params::dd_user}", + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name] + } + file { "${datadog_agent::params::conf_dir}/docker.yaml": + ensure => 'absent' + } + + file { "${datadog_agent::params::conf_dir}/docker_daemon.yaml": ensure => file, owner => $datadog_agent::params::dd_user, group => $datadog_agent::params::dd_group, mode => '0644', - content => template('datadog_agent/agent-conf.d/docker.yaml.erb'), + content => template('datadog_agent/agent-conf.d/docker_daemon.yaml.erb'), require => Package[$datadog_agent::params::package_name], notify => Service[$datadog_agent::params::service_name] } diff --git a/manifests/integrations/mesos.pp b/manifests/integrations/mesos_master.pp similarity index 69% rename from manifests/integrations/mesos.pp rename to manifests/integrations/mesos_master.pp index 7b0ab913..37ac1915 100644 --- a/manifests/integrations/mesos.pp +++ b/manifests/integrations/mesos_master.pp @@ -1,4 +1,4 @@ -# Class: datadog_agent::integrations::mesos +# Class: datadog_agent::integrations::mesos_master # # This class will install the necessary configuration for the mesos integration # @@ -12,17 +12,21 @@ # url => "http://localhost:5050" # } # -class datadog_agent::integrations::mesos( - $mesos_timeout = 5, +class datadog_agent::integrations::mesos_master( + $mesos_timeout = 10, $url = 'http://localhost:5050' ) inherits datadog_agent::params { file { "${datadog_agent::params::conf_dir}/mesos.yaml": + ensure => 'absent' + } + + file { "${datadog_agent::params::conf_dir}/mesos_master.yaml": ensure => file, owner => $datadog_agent::params::dd_user, group => $datadog_agent::params::dd_group, mode => '0644', - content => template('datadog_agent/agent-conf.d/mesos.yaml.erb'), + content => template('datadog_agent/agent-conf.d/mesos_master.yaml.erb'), require => Package[$datadog_agent::params::package_name], notify => Service[$datadog_agent::params::service_name] } diff --git a/manifests/integrations/mesos_slave.pp b/manifests/integrations/mesos_slave.pp new file mode 100644 index 00000000..4b1dffaa --- /dev/null +++ b/manifests/integrations/mesos_slave.pp @@ -0,0 +1,29 @@ +# Class: datadog_agent::integrations::mesos_slave +# +# This class will install the necessary configuration for the mesos slave integration +# +# Parameters: +# $url: +# The URL for Mesos slave +# +# Sample Usage: +# +# class { 'datadog_agent::integrations::mesos' : +# url => "http://localhost:5051" +# } +# +class datadog_agent::integrations::mesos_slave( + $mesos_timeout = 10, + $url = 'http://localhost:5051' +) inherits datadog_agent::params { + + file { "${datadog_agent::params::conf_dir}/mesos_slave.yaml": + ensure => file, + owner => $datadog_agent::params::dd_user, + group => $datadog_agent::params::dd_group, + mode => '0644', + content => template('datadog_agent/agent-conf.d/mesos_slave.yaml.erb'), + require => Package[$datadog_agent::params::package_name], + notify => Service[$datadog_agent::params::service_name] + } +} diff --git a/manifests/redhat.pp b/manifests/redhat.pp index 5d4f148b..5b11b8b5 100644 --- a/manifests/redhat.pp +++ b/manifests/redhat.pp @@ -17,13 +17,13 @@ $baseurl = "https://yum.datadoghq.com/rpm/${::architecture}/", $gpgkey = 'https://yum.datadoghq.com/DATADOG_RPM_KEY.public', $manage_repo = true, + $agent_version = 'latest' ) { validate_bool($manage_repo) if $manage_repo { validate_string($baseurl) - yumrepo {'datadog': enabled => 1, gpgcheck => 1, @@ -32,7 +32,7 @@ baseurl => $baseurl, } - Package['datadog-agent'] -> Yumrepo['datadog'] + Package { require => Yumrepo['datadog']} } package { 'datadog-agent-base': @@ -41,7 +41,7 @@ } package { 'datadog-agent': - ensure => latest, + ensure => $agent_version, } service { 'datadog-agent': diff --git a/templates/agent-conf.d/docker.yaml.erb b/templates/agent-conf.d/docker.yaml.erb deleted file mode 100644 index edbf9e92..00000000 --- a/templates/agent-conf.d/docker.yaml.erb +++ /dev/null @@ -1,17 +0,0 @@ -# -# MANAGED BY PUPPET -# - -init_config: - -instances: - - url: <%= @url %> - new_tag_names: <%= @new_tag_names %> -<% if @tags and ! @tags.empty? -%> - tags: - <%- Array(@tags).each do |tag| -%> - <%- if tag != '' -%> - - <%= tag %> - <%- end -%> - <%- end -%> -<% end -%> diff --git a/templates/agent-conf.d/docker_daemon.yaml.erb b/templates/agent-conf.d/docker_daemon.yaml.erb new file mode 100644 index 00000000..aaf50110 --- /dev/null +++ b/templates/agent-conf.d/docker_daemon.yaml.erb @@ -0,0 +1,115 @@ +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 + + # Timeout in seconds for the connection to the docker daemon + # Default: 5 seconds + # + # timeout: 10 + + # The version of the API the client will use. Specify 'auto' to use the API version provided by the server. + # api_version: auto + + # 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 + +instances: + - ## Daemon and system configuration + ## + + # URL of the Docker daemon socket to reach the Docker API. HTTP/HTTPS also works. + # Warning: if that's a non-local daemon, we won't be able to collect performance metrics. + # + url: <%= @url %> + + ## Data collection + ## + + # Create events whenever a container status change. + # Defaults to true. + # + # collect_events: false + + # 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 images stats + # Number of available active images and intermediate images as gauges. + # Defaults to false. + # + # collect_images_stats: false + + # 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 + + + # Exclude containers based on their tags + # An excluded container will be completely ignored. The rule is a regex on the tags. + # + # How it works: exclude first. + # If a tag matches an exclude rule, it won't be included unless it also matches an include rule. + # Examples: + # exclude all, except ubuntu and debian. + # exclude: [".*"] + # include: ["docker_image:ubuntu", "docker_image:debian"] + # + # include all, except ubuntu and debian. + # exclude: ["docker_image:ubuntu", "docker_image:debian"] + # include: [] + # + # Default: include all containers + + + + ## Tagging + ## + + # You can add extra tags to your Docker metrics with the tags list option. + # Example: ["extra_tag", "env:testing"] + # + # tags: [] + + # 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 + + # Custom metrics tagging + # Define which Docker tags to apply on metrics. + # Since it impacts the aggregation, modify it carefully (only if you really need it). + # + # Tags for performance metrics. + # Available: + # - image_name: Name of the image (example: "nginx") + # - image_tag: Tag of the image (example: "latest") + # - docker_image: LEGACY. The full image name:tag string (example: "nginx:latest") + # - 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"] + + # Tags for containers count metrics. + # Available: ["image_name", "image_tag", "docker_image", "container_command"] + # + # container_tags: ["image_name", "image_tag", "docker_image"] + + # 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"] \ No newline at end of file diff --git a/templates/agent-conf.d/mesos.yaml.erb b/templates/agent-conf.d/mesos_master.yaml.erb similarity index 58% rename from templates/agent-conf.d/mesos.yaml.erb rename to templates/agent-conf.d/mesos_master.yaml.erb index 1d4ee99d..bb67c598 100644 --- a/templates/agent-conf.d/mesos.yaml.erb +++ b/templates/agent-conf.d/mesos_master.yaml.erb @@ -1,8 +1,6 @@ -# -# MANAGED BY PUPPET -# init_config: default_timeout: <%= @mesos_timeout %> + instances: - - url: <%= @url %> + - url: <%= @url %> \ No newline at end of file diff --git a/templates/agent-conf.d/mesos_slave.yaml.erb b/templates/agent-conf.d/mesos_slave.yaml.erb new file mode 100644 index 00000000..17c2e594 --- /dev/null +++ b/templates/agent-conf.d/mesos_slave.yaml.erb @@ -0,0 +1,7 @@ +init_config: + default_timeout: <%= @mesos_timeout %> + +instances: + - url: <%= @url %> + # tasks: + # - "hello" \ No newline at end of file diff --git a/templates/datadog.conf.erb b/templates/datadog.conf.erb index feb7dd15..779cef13 100644 --- a/templates/datadog.conf.erb +++ b/templates/datadog.conf.erb @@ -79,9 +79,6 @@ collect_instance_metadata: <%= @collect_instance_metadata %> # Defaults to 30 seconds if no value is provided #recent_point_threshold: 30 -# Use mount points instead of volumes to track disk and fs metrics -use_mount: <%= @use_mount %> - # Change port the Agent is listening to # listen_port: 17123