summary refs log tree commit diff
path: root/nixos/modules/services/monitoring/prometheus/exporters/fastly.nix
diff options
context:
space:
mode:
authorSouvik Sen <nixpkgs-commits@deshaw.com>2021-08-12 03:30:27 -0400
committerSouvik Sen <senso@deshaw.com>2021-09-21 04:05:18 -0400
commit2f669293bfb99dd71bb9e69048aee7132b060870 (patch)
treea184af084773192e60dbe89921e28dbb18c00994 /nixos/modules/services/monitoring/prometheus/exporters/fastly.nix
parent9df2cb074d72ea80ac9fd225b29060c8cf13dd39 (diff)
downloadnixpkgs-2f669293bfb99dd71bb9e69048aee7132b060870.tar
nixpkgs-2f669293bfb99dd71bb9e69048aee7132b060870.tar.gz
nixpkgs-2f669293bfb99dd71bb9e69048aee7132b060870.tar.bz2
nixpkgs-2f669293bfb99dd71bb9e69048aee7132b060870.tar.lz
nixpkgs-2f669293bfb99dd71bb9e69048aee7132b060870.tar.xz
nixpkgs-2f669293bfb99dd71bb9e69048aee7132b060870.tar.zst
nixpkgs-2f669293bfb99dd71bb9e69048aee7132b060870.zip
prometheus-fastly-exporter: init at v6.1.0
Diffstat (limited to 'nixos/modules/services/monitoring/prometheus/exporters/fastly.nix')
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters/fastly.nix41
1 files changed, 41 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/fastly.nix b/nixos/modules/services/monitoring/prometheus/exporters/fastly.nix
new file mode 100644
index 00000000000..5b35bb29a30
--- /dev/null
+++ b/nixos/modules/services/monitoring/prometheus/exporters/fastly.nix
@@ -0,0 +1,41 @@
+{ config, lib, pkgs, options }:
+
+with lib;
+
+let cfg = config.services.prometheus.exporters.fastly;
+in
+{
+  port = 9118;
+  extraOpts = {
+    debug = mkEnableOption "Debug logging mode for fastly-exporter";
+
+    configFile = mkOption {
+      type = types.nullOr types.path;
+      default = null;
+      description = ''
+        Path to a fastly-exporter configuration file.
+        Example one can be generated with <literal>fastly-exporter --config-file-example</literal>.
+      '';
+      example = "./fastly-exporter-config.txt";
+    };
+
+    tokenPath = mkOption {
+      type = types.nullOr types.path;
+      apply = final: if final == null then null else toString final;
+      description = ''
+        A run-time path to the token file, which is supposed to be provisioned
+        outside of Nix store.
+      '';
+    };
+  };
+  serviceOpts = {
+    script = ''
+      ${optionalString (cfg.tokenPath != null)
+      "export FASTLY_API_TOKEN=$(cat ${toString cfg.tokenPath})"}
+      ${pkgs.fastly-exporter}/bin/fastly-exporter \
+        -endpoint http://${cfg.listenAddress}:${cfg.port}/metrics
+        ${optionalString cfg.debug "-debug true"} \
+        ${optionalString cfg.configFile "-config-file ${cfg.configFile}"}
+    '';
+  };
+}