summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorGraham Christensen <graham@grahamc.com>2021-09-27 11:09:33 -0400
committerGitHub <noreply@github.com>2021-09-27 11:09:33 -0400
commit6c88e85807ca8ad7348f514fd8ef6056e11a9cee (patch)
tree19caa3101bc12bfc72b3adc2f0bebf91f212518e /nixos/modules
parentaf45dae72dc6288f07af7af0dd1b93f9c906065b (diff)
parent2f669293bfb99dd71bb9e69048aee7132b060870 (diff)
downloadnixpkgs-6c88e85807ca8ad7348f514fd8ef6056e11a9cee.tar
nixpkgs-6c88e85807ca8ad7348f514fd8ef6056e11a9cee.tar.gz
nixpkgs-6c88e85807ca8ad7348f514fd8ef6056e11a9cee.tar.bz2
nixpkgs-6c88e85807ca8ad7348f514fd8ef6056e11a9cee.tar.lz
nixpkgs-6c88e85807ca8ad7348f514fd8ef6056e11a9cee.tar.xz
nixpkgs-6c88e85807ca8ad7348f514fd8ef6056e11a9cee.tar.zst
nixpkgs-6c88e85807ca8ad7348f514fd8ef6056e11a9cee.zip
Merge pull request #133726 from deshaw/fastly-exporter
prometheus-fastly-exporter: init at v6.1.0
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters.nix1
-rw-r--r--nixos/modules/services/monitoring/prometheus/exporters/fastly.nix41
2 files changed, 42 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix
index 9182c2f2ed8..83de9a3f5eb 100644
--- a/nixos/modules/services/monitoring/prometheus/exporters.nix
+++ b/nixos/modules/services/monitoring/prometheus/exporters.nix
@@ -32,6 +32,7 @@ let
     "dnsmasq"
     "domain"
     "dovecot"
+    "fastly"
     "fritzbox"
     "influxdb"
     "json"
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}"}
+    '';
+  };
+}