about summary refs log tree commit diff
path: root/modules/services/monitoring
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2013-01-08 16:19:51 -0500
committerShea Levy <shea@shealevy.com>2013-01-08 16:19:51 -0500
commit19127aa4165b8aae6ca29dc7a80d21bd0b40dfe4 (patch)
treecdf64d0d1105120cfd6e9a9ed326ed2ccdfb342b /modules/services/monitoring
parentac53b25f167746cff0885ee28c6a172a43b81984 (diff)
downloadnixlib-19127aa4165b8aae6ca29dc7a80d21bd0b40dfe4.tar
nixlib-19127aa4165b8aae6ca29dc7a80d21bd0b40dfe4.tar.gz
nixlib-19127aa4165b8aae6ca29dc7a80d21bd0b40dfe4.tar.bz2
nixlib-19127aa4165b8aae6ca29dc7a80d21bd0b40dfe4.tar.lz
nixlib-19127aa4165b8aae6ca29dc7a80d21bd0b40dfe4.tar.xz
nixlib-19127aa4165b8aae6ca29dc7a80d21bd0b40dfe4.tar.zst
nixlib-19127aa4165b8aae6ca29dc7a80d21bd0b40dfe4.zip
Add dd-agent module
Diffstat (limited to 'modules/services/monitoring')
-rw-r--r--modules/services/monitoring/dd-agent.nix58
1 files changed, 58 insertions, 0 deletions
diff --git a/modules/services/monitoring/dd-agent.nix b/modules/services/monitoring/dd-agent.nix
new file mode 100644
index 000000000000..c0493557d56d
--- /dev/null
+++ b/modules/services/monitoring/dd-agent.nix
@@ -0,0 +1,58 @@
+{ config, pkgs, ... }:
+
+with pkgs.lib;
+
+let
+  cfg = config.services.dd-agent;
+
+  datadog-conf = pkgs.runCommand "datadog.conf" {} ''
+    sed -e 's|^api_key:|api_key: ${cfg.api_key}|' ${optionalString (cfg.hostname != null)
+      "-e 's|^#hostname: mymachine.mydomain|hostname: ${cfg.hostname}|'"
+    } ${pkgs.dd-agent}/etc/dd-agent/datadog.conf.example > $out
+  '';
+in {
+  options.services.dd-agent = {
+    enable = mkOption {
+      description = "Whether to enable the dd-agent montioring service";
+
+      default = false;
+
+      type = types.bool;
+    };
+
+    # !!! This gets stored in the store (world-readable), wish we had https://github.com/NixOS/nix/issues/8
+    api_key = mkOption {
+      description = "The Datadog API key to associate the agent with your account";
+
+      example = "ae0aa6a8f08efa988ba0a17578f009ab";
+
+      type = types.uniq types.string;
+    };
+
+    hostname = mkOption {
+      description = "The hostname to show in the Datadog dashboard (optional)";
+
+      default = null;
+
+      example = "mymachine.mydomain";
+
+      type = types.uniq (types.nullOr types.string);
+    };
+  };
+
+  config = mkIf cfg.enable {
+    environment.etc = [ { source = datadog-conf; target = "dd-agent/datadog.conf"; } ];
+
+    boot.systemd.services.dd-agent = {
+      description = "Datadog agent monitor";
+
+      path = [ pkgs.sysstat pkgs.procps ];
+
+      wantedBy = [ "multi-user.target" ];
+
+      serviceConfig.ExecStart = "${pkgs.dd-agent}/bin/dd-agent foreground";
+
+      restartTriggers = [ pkgs.dd-agent ];
+    };
+  };
+}