Revert "dd-agent: 5.11.2 -> 5.13.2 + service rework"

This reverts commit af096c8bff1e534be9c69f50eed13e6b48427d0e.

+169 -95
+8
nixos/modules/services/monitoring/dd-agent/dd-agent-defaults.nix
··· 1 + # Generated using update-dd-agent-default, please re-run after updating dd-agent. DO NOT EDIT MANUALLY. 2 + [ 3 + "auto_conf" 4 + "agent_metrics.yaml.default" 5 + "disk.yaml.default" 6 + "network.yaml.default" 7 + "ntp.yaml.default" 8 + ]
+140 -50
nixos/modules/services/monitoring/dd-agent/dd-agent.nix
··· 16 16 forwarder_log_file: /var/log/datadog/forwarder.log 17 17 dogstatsd_log_file: /var/log/datadog/dogstatsd.log 18 18 pup_log_file: /var/log/datadog/pup.log 19 + 20 + # proxy_host: my-proxy.com 21 + # proxy_port: 3128 22 + # proxy_user: user 23 + # proxy_password: password 24 + 25 + # tags: mytag0, mytag1 19 26 ${optionalString (cfg.tags != null ) "tags: ${concatStringsSep "," cfg.tags }"} 20 - ${cfg.extraDdConfig} 27 + 28 + # collect_ec2_tags: no 29 + # recent_point_threshold: 30 30 + # use_mount: no 31 + # listen_port: 17123 32 + # graphite_listen_port: 17124 33 + # non_local_traffic: no 34 + # use_curl_http_client: False 35 + # bind_host: localhost 36 + 37 + # use_pup: no 38 + # pup_port: 17125 39 + # pup_interface: localhost 40 + # pup_url: http://localhost:17125 41 + 42 + # dogstatsd_port : 8125 43 + # dogstatsd_interval : 10 44 + # dogstatsd_normalize : yes 45 + # statsd_forward_host: address_of_own_statsd_server 46 + # statsd_forward_port: 8125 47 + 48 + # device_blacklist_re: .*\/dev\/mapper\/lxc-box.* 49 + 50 + # ganglia_host: localhost 51 + # ganglia_port: 8651 21 52 ''; 22 53 23 - etcfiles = 24 - map (i: { source = if builtins.hasAttr "config" i 25 - then pkgs.writeText "${i.name}.yaml" i.config 26 - else "${pkgs.dd-agent}/agent/conf.d-system/${i.name}.yaml"; 27 - target = "dd-agent/conf.d/${i.name}.yaml"; 28 - } 29 - ) cfg.integrations ++ 30 - [ { source = ddConf; 31 - target = "dd-agent/datadog.conf"; 32 - } 33 - ]; 54 + diskConfig = pkgs.writeText "disk.yaml" '' 55 + init_config: 34 56 35 - # restart triggers 36 - etcSources = map (i: i.source) etcfiles; 57 + instances: 58 + - use_mount: no 59 + ''; 60 + 61 + networkConfig = pkgs.writeText "network.yaml" '' 62 + init_config: 63 + 64 + instances: 65 + # Network check only supports one configured instance 66 + - collect_connection_state: false 67 + excluded_interfaces: 68 + - lo 69 + - lo0 70 + ''; 71 + 72 + postgresqlConfig = pkgs.writeText "postgres.yaml" cfg.postgresqlConfig; 73 + nginxConfig = pkgs.writeText "nginx.yaml" cfg.nginxConfig; 74 + mongoConfig = pkgs.writeText "mongo.yaml" cfg.mongoConfig; 75 + jmxConfig = pkgs.writeText "jmx.yaml" cfg.jmxConfig; 76 + processConfig = pkgs.writeText "process.yaml" cfg.processConfig; 77 + 78 + etcfiles = 79 + let 80 + defaultConfd = import ./dd-agent-defaults.nix; 81 + in (map (f: { source = "${pkgs.dd-agent}/agent/conf.d-system/${f}"; 82 + target = "dd-agent/conf.d/${f}"; 83 + }) defaultConfd) ++ [ 84 + { source = ddConf; 85 + target = "dd-agent/datadog.conf"; 86 + } 87 + { source = diskConfig; 88 + target = "dd-agent/conf.d/disk.yaml"; 89 + } 90 + { source = networkConfig; 91 + target = "dd-agent/conf.d/network.yaml"; 92 + } ] ++ 93 + (optional (cfg.postgresqlConfig != null) 94 + { source = postgresqlConfig; 95 + target = "dd-agent/conf.d/postgres.yaml"; 96 + }) ++ 97 + (optional (cfg.nginxConfig != null) 98 + { source = nginxConfig; 99 + target = "dd-agent/conf.d/nginx.yaml"; 100 + }) ++ 101 + (optional (cfg.mongoConfig != null) 102 + { source = mongoConfig; 103 + target = "dd-agent/conf.d/mongo.yaml"; 104 + }) ++ 105 + (optional (cfg.processConfig != null) 106 + { source = processConfig; 107 + target = "dd-agent/conf.d/process.yaml"; 108 + }) ++ 109 + (optional (cfg.jmxConfig != null) 110 + { source = jmxConfig; 111 + target = "dd-agent/conf.d/jmx.yaml"; 112 + }); 37 113 38 114 in { 39 115 options.services.dd-agent = { ··· 63 139 type = types.uniq (types.nullOr types.string); 64 140 }; 65 141 66 - agent = mkOption { 67 - description = "The dd-agent package to use. Useful when overriding the package."; 68 - default = pkgs.dd-agent; 69 - type = types.package; 142 + postgresqlConfig = mkOption { 143 + description = "Datadog PostgreSQL integration configuration"; 144 + default = null; 145 + type = types.uniq (types.nullOr types.string); 70 146 }; 71 147 72 - integrations = mkOption { 148 + nginxConfig = mkOption { 149 + description = "Datadog nginx integration configuration"; 150 + default = null; 151 + type = types.uniq (types.nullOr types.string); 152 + }; 153 + 154 + mongoConfig = mkOption { 155 + description = "MongoDB integration configuration"; 156 + default = null; 157 + type = types.uniq (types.nullOr types.string); 158 + }; 159 + 160 + jmxConfig = mkOption { 161 + description = "JMX integration configuration"; 162 + default = null; 163 + type = types.uniq (types.nullOr types.string); 164 + }; 165 + 166 + processConfig = mkOption { 73 167 description = '' 74 - Any integrations to use. Default config used if none 75 - specified. It is currently up to the user to make sure that 76 - the dd-agent package used has all the dependencies chosen 77 - integrations require in scope. 168 + Process integration configuration 169 + 170 + See http://docs.datadoghq.com/integrations/process/ 78 171 ''; 79 - type = types.listOf (types.attrsOf types.string); 80 - default = []; 81 - example = '' 82 - [ { name = "elastic"; 83 - config = ''' 84 - init_config: 85 - 86 - instances: 87 - - url: http://localhost:9200 88 - '''; 89 - } 90 - { name = "nginx"; } 91 - { name = "ntp"; } 92 - { name = "network"; } 93 - ] 94 - ''; 172 + default = null; 173 + type = types.uniq (types.nullOr types.string); 95 174 }; 96 175 97 - extraDdConfig = mkOption { 98 - description = "Extra settings to append to datadog agent config."; 99 - default = ""; 100 - type = types.string; 101 - }; 102 176 }; 103 177 104 178 config = mkIf cfg.enable { 105 - environment.systemPackages = [ cfg.agent pkgs.sysstat pkgs.procps ]; 179 + environment.systemPackages = [ pkgs."dd-agent" pkgs.sysstat pkgs.procps ]; 106 180 107 181 users.extraUsers.datadog = { 108 182 description = "Datadog Agent User"; ··· 116 190 117 191 systemd.services.dd-agent = { 118 192 description = "Datadog agent monitor"; 119 - path = [ cfg.agent pkgs.python pkgs.sysstat pkgs.procps ]; 193 + path = [ pkgs."dd-agent" pkgs.python pkgs.sysstat pkgs.procps ]; 120 194 wantedBy = [ "multi-user.target" ]; 121 195 serviceConfig = { 122 196 ExecStart = "${pkgs.dd-agent}/bin/dd-agent foreground"; ··· 125 199 Restart = "always"; 126 200 RestartSec = 2; 127 201 }; 128 - restartTriggers = [ pkgs.dd-agent ddConf ] ++ etcSources; 202 + restartTriggers = [ pkgs.dd-agent ddConf diskConfig networkConfig postgresqlConfig nginxConfig mongoConfig jmxConfig processConfig ]; 203 + }; 204 + 205 + systemd.services.dogstatsd = { 206 + description = "Datadog statsd"; 207 + path = [ pkgs."dd-agent" pkgs.python pkgs.procps ]; 208 + wantedBy = [ "multi-user.target" ]; 209 + serviceConfig = { 210 + ExecStart = "${pkgs.dd-agent}/bin/dogstatsd start"; 211 + User = "datadog"; 212 + Group = "datadog"; 213 + Type = "forking"; 214 + PIDFile = "/tmp/dogstatsd.pid"; 215 + Restart = "always"; 216 + RestartSec = 2; 217 + }; 218 + restartTriggers = [ pkgs.dd-agent ddConf diskConfig networkConfig postgresqlConfig nginxConfig mongoConfig jmxConfig processConfig ]; 129 219 }; 130 220 131 - systemd.services.dd-jmxfetch = lib.mkIf (builtins.any (i: i.name == "jmx") cfg.integrations) { 221 + systemd.services.dd-jmxfetch = lib.mkIf (cfg.jmxConfig != null) { 132 222 description = "Datadog JMX Fetcher"; 133 - path = [ cfg.agent pkgs.python pkgs.sysstat pkgs.procps pkgs.jdk ]; 223 + path = [ pkgs."dd-agent" pkgs.python pkgs.sysstat pkgs.procps pkgs.jdk ]; 134 224 wantedBy = [ "multi-user.target" ]; 135 225 serviceConfig = { 136 226 ExecStart = "${pkgs.dd-agent}/bin/dd-jmxfetch"; ··· 139 229 Restart = "always"; 140 230 RestartSec = 2; 141 231 }; 142 - restartTriggers = [ cfg.agent ddConf ] ++ etcSources; 232 + restartTriggers = [ pkgs.dd-agent ddConf diskConfig networkConfig postgresqlConfig nginxConfig mongoConfig jmxConfig ]; 143 233 }; 144 234 145 235 environment.etc = etcfiles;
+9
nixos/modules/services/monitoring/dd-agent/update-dd-agent-defaults
··· 1 + #!/usr/bin/env bash 2 + dd=$(nix-build --no-out-link -A dd-agent ../../../..) 3 + echo '# Generated using update-dd-agent-default, please re-run after updating dd-agent. DO NOT EDIT MANUALLY.' > dd-agent-defaults.nix 4 + echo '[' >> dd-agent-defaults.nix 5 + echo ' "auto_conf"' >> dd-agent-defaults.nix 6 + for f in $(find $dd/agent/conf.d-system -maxdepth 1 -type f | grep -v '\.example' | sort); do 7 + echo " \"$(basename $f)\"" >> dd-agent-defaults.nix 8 + done 9 + echo ']' >> dd-agent-defaults.nix
+12 -45
pkgs/tools/networking/dd-agent/default.nix
··· 1 1 { stdenv, fetchFromGitHub, pythonPackages 2 - , sysstat, unzip, makeWrapper 3 - # We need extraBuildInputs as we want to be able to override this 4 - # package with python packages _and_ have the produced binaries 5 - # wrapper with their PYTHONPATH. This means overrideAttrs is not 6 - # strong enough (it overrides too late), we need to call it 7 - # beforehand. 8 - , extraBuildInputs ? [ pythonPackages.psutil ] }: 2 + , sysstat, unzip, makeWrapper }: 9 3 let 10 4 inherit (pythonPackages) python; 11 5 docker_1_10 = pythonPackages.buildPythonPackage rec { ··· 32 26 # due to flake8 33 27 doCheck = false; 34 28 }; 35 - version = "5.13.2"; 36 - 37 - integrations = fetchFromGitHub { 38 - owner = "datadog"; 39 - repo = "integrations-core"; 40 - rev = version; 41 - sha256 = "1nbjmkq0wdfndmx0qap69h2rkwkkb0632j87h9d3j99bykyav3y3"; 42 - }; 43 29 44 30 in stdenv.mkDerivation rec { 31 + version = "5.11.2"; 45 32 name = "dd-agent-${version}"; 46 33 47 34 src = fetchFromGitHub { 48 35 owner = "datadog"; 49 36 repo = "dd-agent"; 50 37 rev = version; 51 - sha256 = "0x2bxi70l2yf0wi232qksvcscjdpjg8l7dmgg1286vqryyfazfjb"; 38 + sha256 = "1iqxvgpsqibqw3vk79158l2pnb6y4pjhjp2d6724lm5rpz4825lx"; 52 39 }; 53 40 54 41 buildInputs = [ 55 42 python 56 43 unzip 57 44 makeWrapper 58 - pythonPackages.boto 59 - docker_1_10 60 - pythonPackages.kazoo 45 + pythonPackages.requests 46 + pythonPackages.psycopg2 47 + pythonPackages.psutil 61 48 pythonPackages.ntplib 49 + pythonPackages.simplejson 50 + pythonPackages.pyyaml 51 + pythonPackages.pymongo_2_9_1 52 + pythonPackages.python-etcd 62 53 pythonPackages.consul 63 - pythonPackages.python-etcd 64 - pythonPackages.pyyaml 65 - pythonPackages.requests 66 - pythonPackages.simplejson 67 - pythonPackages.supervisor 68 - pythonPackages.tornado 69 - pythonPackages.uptime 70 - ] ++ extraBuildInputs; 54 + docker_1_10 55 + ]; 71 56 propagatedBuildInputs = with pythonPackages; [ python tornado ]; 72 57 73 58 buildCommand = '' ··· 81 66 82 67 # Move out default conf.d so that /etc/dd-agent/conf.d is used 83 68 mv $out/agent/conf.d $out/agent/conf.d-system 84 - 85 - # Sometime between 5.11.2 and 5.13.2 datadog moved out all its 86 - # checks into separate repository. Copy them back in so dd-agent 87 - # service can easily pick and choose by copying out configs into 88 - # its etc files. 89 - mkdir -p $out/agent/checks.d 90 - for i in ${toString integrations}/* # */ 91 - do 92 - if [ -f "$i/check.py" ]; then 93 - if [ -f "$i/conf.yaml.default" -o -f "$i/conf.yaml.example" ]; then 94 - local name=$(basename $i) 95 - cp $i/check.py $out/agent/checks.d/$name.py 96 - # Copy .default file first unless it doesn't exist then copy .default 97 - cp $i/conf.yaml.default $out/agent/conf.d-system/$name.yaml &> /dev/null || \ 98 - cp $i/conf.yaml.example $out/agent/conf.d-system/$name.yaml 99 - fi 100 - fi 101 - done 102 69 103 70 cat > $out/bin/dd-jmxfetch <<EOF 104 71 #!/usr/bin/env bash