lol

prometheus module: add blackboxExporter

authored by

Corbin and committed by
Robin Gloster
618b249f bd45d5fe

+58
+1
nixos/modules/module-list.nix
··· 309 309 ./services/monitoring/nagios.nix 310 310 ./services/monitoring/prometheus/default.nix 311 311 ./services/monitoring/prometheus/alertmanager.nix 312 + ./services/monitoring/prometheus/blackbox-exporter.nix 312 313 ./services/monitoring/prometheus/json-exporter.nix 313 314 ./services/monitoring/prometheus/nginx-exporter.nix 314 315 ./services/monitoring/prometheus/node-exporter.nix
+57
nixos/modules/services/monitoring/prometheus/blackbox-exporter.nix
··· 1 + { config, pkgs, lib, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.services.prometheus.blackboxExporter; 7 + in { 8 + options = { 9 + services.prometheus.blackboxExporter = { 10 + enable = mkEnableOption "prometheus blackbox exporter"; 11 + 12 + configFile = mkOption { 13 + type = types.path; 14 + description = '' 15 + Path to configuration file. 16 + ''; 17 + }; 18 + 19 + port = mkOption { 20 + type = types.int; 21 + default = 9115; 22 + description = '' 23 + Port to listen on. 24 + ''; 25 + }; 26 + 27 + extraFlags = mkOption { 28 + type = types.listOf types.str; 29 + default = []; 30 + description = '' 31 + Extra commandline options when launching the blackbox exporter. 32 + ''; 33 + }; 34 + }; 35 + }; 36 + 37 + config = mkIf cfg.enable { 38 + systemd.services.prometheus-blackbox-exporter = { 39 + description = "Prometheus exporter for blackbox probes"; 40 + unitConfig.Documentation = "https://github.com/prometheus/blackbox_exporter"; 41 + wantedBy = [ "multi-user.target" ]; 42 + serviceConfig = { 43 + User = "nobody"; 44 + Restart = "always"; 45 + PrivateTmp = true; 46 + WorkingDirectory = /tmp; 47 + ExecStart = '' 48 + ${pkgs.prometheus-blackbox-exporter}/bin/blackbox_exporter \ 49 + -web.listen-address :${toString cfg.port} \ 50 + -config.file ${cfg.configFile} \ 51 + ${concatStringsSep " \\\n " cfg.extraFlags} 52 + ''; 53 + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; 54 + }; 55 + }; 56 + }; 57 + }