about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorSamuel Leathers <samuel.leathers@iohk.io>2018-04-06 12:02:10 -0400
committerSamuel Leathers <samuel.leathers@iohk.io>2018-10-27 05:15:03 -0400
commit5b30cd77db41a5ef96cca35ff2f4fa10a1577d20 (patch)
tree02c4c8a7697e15bffc48e9980ddd6e3377da87c8 /nixos
parent5573795901f2d0fb29c6f1f9e7dc765f2d4158ae (diff)
downloadnixlib-5b30cd77db41a5ef96cca35ff2f4fa10a1577d20.tar
nixlib-5b30cd77db41a5ef96cca35ff2f4fa10a1577d20.tar.gz
nixlib-5b30cd77db41a5ef96cca35ff2f4fa10a1577d20.tar.bz2
nixlib-5b30cd77db41a5ef96cca35ff2f4fa10a1577d20.tar.lz
nixlib-5b30cd77db41a5ef96cca35ff2f4fa10a1577d20.tar.xz
nixlib-5b30cd77db41a5ef96cca35ff2f4fa10a1577d20.tar.zst
nixlib-5b30cd77db41a5ef96cca35ff2f4fa10a1577d20.zip
nixos/grafana_reporter: initial service
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/module-list.nix1
-rw-r--r--nixos/modules/services/monitoring/grafana-reporter.nix66
2 files changed, 67 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index fb6b4262568e..5090533e1c7c 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -427,6 +427,7 @@
   ./services/monitoring/dd-agent/dd-agent.nix
   ./services/monitoring/fusion-inventory.nix
   ./services/monitoring/grafana.nix
+  ./services/monitoring/grafana-reporter.nix
   ./services/monitoring/graphite.nix
   ./services/monitoring/hdaps.nix
   ./services/monitoring/heapster.nix
diff --git a/nixos/modules/services/monitoring/grafana-reporter.nix b/nixos/modules/services/monitoring/grafana-reporter.nix
new file mode 100644
index 000000000000..149026d20188
--- /dev/null
+++ b/nixos/modules/services/monitoring/grafana-reporter.nix
@@ -0,0 +1,66 @@
+{ options, config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.grafana_reporter;
+
+in {
+  options.services.grafana_reporter = {
+    enable = mkEnableOption "grafana_reporter";
+
+    grafana = {
+      protocol = mkOption {
+        description = "Grafana protocol.";
+        default = "http";
+        type = types.enum ["http" "https"];
+      };
+      addr = mkOption {
+        description = "Grafana address.";
+        default = "127.0.0.1";
+        type = types.str;
+      };
+      port = mkOption {
+        description = "Grafana port.";
+        default = 3000;
+        type = types.int;
+      };
+
+    };
+    addr = mkOption {
+      description = "Listening address.";
+      default = "127.0.0.1";
+      type = types.str;
+    };
+
+    port = mkOption {
+      description = "Listening port.";
+      default = 8686;
+      type = types.int;
+    };
+
+    templateDir = mkOption {
+      description = "Optional template directory to use custom tex templates";
+      default = "${pkgs.grafana_reporter}";
+      type = types.str;
+    };
+  };
+
+  config = mkIf cfg.enable {
+    systemd.services.grafana_reporter = {
+      description = "Grafana Reporter Service Daemon";
+      wantedBy = ["multi-user.target"];
+      after = ["network.target"];
+      serviceConfig = let
+        args = lib.concatSepString " " [
+          "-proto ${cfg.grafana.protocol}://"
+          "-ip ${cfg.grafana.addr}:${toString cfg.grafana.port}"
+          "-port :${toString cfg.port}"
+          "-templates ${cfg.templateDir}"
+        ];
+      in {
+        ExecStart = "${pkgs.grafana_reporter.bin}/bin/grafana-reporter ${args}";
+      };
+    };
+  };
+}