diff options
4 files changed, 65 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}"} + ''; + }; +} diff --git a/pkgs/servers/monitoring/prometheus/fastly-exporter.nix b/pkgs/servers/monitoring/prometheus/fastly-exporter.nix new file mode 100644 index 00000000000..cffdca4083c --- /dev/null +++ b/pkgs/servers/monitoring/prometheus/fastly-exporter.nix @@ -0,0 +1,22 @@ +{ lib, buildGoModule, fetchFromGitHub }: + +buildGoModule rec { + pname = "fastly-exporter"; + version = "6.1.0"; + + src = fetchFromGitHub { + owner = "peterbourgon"; + repo = pname; + rev = "v${version}"; + sha256 = "0my0pcxix5rk73m5ciz513nwmjcm7vjs6r8wg3vddm0xixv7zq94"; + }; + + vendorSha256 = "1w9asky8h8l5gc0c6cv89m38qw50hyhma8qbsw3zirplhk9mb3r2"; + + meta = with lib; { + description = "Prometheus exporter for the Fastly Real-time Analytics API"; + homepage = "https://github.com/peterbourgon/fastly-exporter"; + license = licenses.asl20; + maintainers = teams.deshaw.members; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3c7a13f0870..d9c69c7e4cb 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -20334,6 +20334,7 @@ with pkgs; prometheus-dnsmasq-exporter = callPackage ../servers/monitoring/prometheus/dnsmasq-exporter.nix { }; prometheus-dovecot-exporter = callPackage ../servers/monitoring/prometheus/dovecot-exporter.nix { }; prometheus-domain-exporter = callPackage ../servers/monitoring/prometheus/domain-exporter.nix { }; + prometheus-fastly-exporter = callPackage ../servers/monitoring/prometheus/fastly-exporter.nix { }; prometheus-flow-exporter = callPackage ../servers/monitoring/prometheus/flow-exporter.nix { }; prometheus-fritzbox-exporter = callPackage ../servers/monitoring/prometheus/fritzbox-exporter.nix { }; prometheus-gitlab-ci-pipelines-exporter = callPackage ../servers/monitoring/prometheus/gitlab-ci-pipelines-exporter.nix { }; |