diff options
author | Corbin <cds@corbinsimpson.com> | 2017-01-08 19:25:17 -0800 |
---|---|---|
committer | Robin Gloster <mail@glob.in> | 2017-01-09 15:20:26 +0100 |
commit | 618b249fc5b8b86423cc52da5a263bfeb5030e40 (patch) | |
tree | 672a95743a578b935e3d58ddb3bdc0750bd378da /nixos/modules/services/monitoring | |
parent | bd45d5fe8d2efbd81648122f890b9ee1e454f699 (diff) | |
download | nixlib-618b249fc5b8b86423cc52da5a263bfeb5030e40.tar nixlib-618b249fc5b8b86423cc52da5a263bfeb5030e40.tar.gz nixlib-618b249fc5b8b86423cc52da5a263bfeb5030e40.tar.bz2 nixlib-618b249fc5b8b86423cc52da5a263bfeb5030e40.tar.lz nixlib-618b249fc5b8b86423cc52da5a263bfeb5030e40.tar.xz nixlib-618b249fc5b8b86423cc52da5a263bfeb5030e40.tar.zst nixlib-618b249fc5b8b86423cc52da5a263bfeb5030e40.zip |
prometheus module: add blackboxExporter
Diffstat (limited to 'nixos/modules/services/monitoring')
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/blackbox-exporter.nix | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/blackbox-exporter.nix b/nixos/modules/services/monitoring/prometheus/blackbox-exporter.nix new file mode 100644 index 000000000000..a1ecd6ef58cd --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/blackbox-exporter.nix @@ -0,0 +1,57 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.services.prometheus.blackboxExporter; +in { + options = { + services.prometheus.blackboxExporter = { + enable = mkEnableOption "prometheus blackbox exporter"; + + configFile = mkOption { + type = types.path; + description = '' + Path to configuration file. + ''; + }; + + port = mkOption { + type = types.int; + default = 9115; + description = '' + Port to listen on. + ''; + }; + + extraFlags = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Extra commandline options when launching the blackbox exporter. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.services.prometheus-blackbox-exporter = { + description = "Prometheus exporter for blackbox probes"; + unitConfig.Documentation = "https://github.com/prometheus/blackbox_exporter"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + User = "nobody"; + Restart = "always"; + PrivateTmp = true; + WorkingDirectory = /tmp; + ExecStart = '' + ${pkgs.prometheus-blackbox-exporter}/bin/blackbox_exporter \ + -web.listen-address :${toString cfg.port} \ + -config.file ${cfg.configFile} \ + ${concatStringsSep " \\\n " cfg.extraFlags} + ''; + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; + }; + }; + }; +} |