diff options
author | Corbin <cds@corbinsimpson.com> | 2016-12-25 21:36:16 -0800 |
---|---|---|
committer | Robin Gloster <mail@glob.in> | 2017-01-09 15:20:26 +0100 |
commit | bd45d5fe8d2efbd81648122f890b9ee1e454f699 (patch) | |
tree | 59ddfe49557cd7f229df3732fc0eb0e4ad862d24 | |
parent | 1e5de5fc3c8a9e560c7d63d7752cb4d96f26093b (diff) | |
download | nixlib-bd45d5fe8d2efbd81648122f890b9ee1e454f699.tar nixlib-bd45d5fe8d2efbd81648122f890b9ee1e454f699.tar.gz nixlib-bd45d5fe8d2efbd81648122f890b9ee1e454f699.tar.bz2 nixlib-bd45d5fe8d2efbd81648122f890b9ee1e454f699.tar.lz nixlib-bd45d5fe8d2efbd81648122f890b9ee1e454f699.tar.xz nixlib-bd45d5fe8d2efbd81648122f890b9ee1e454f699.tar.zst nixlib-bd45d5fe8d2efbd81648122f890b9ee1e454f699.zip |
prometheus module: add jsonExporter
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/json-exporter.nix | 64 |
2 files changed, 65 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index db8c52199255..dcba8a2a21d4 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -309,6 +309,7 @@ ./services/monitoring/nagios.nix ./services/monitoring/prometheus/default.nix ./services/monitoring/prometheus/alertmanager.nix + ./services/monitoring/prometheus/json-exporter.nix ./services/monitoring/prometheus/nginx-exporter.nix ./services/monitoring/prometheus/node-exporter.nix ./services/monitoring/prometheus/snmp-exporter.nix diff --git a/nixos/modules/services/monitoring/prometheus/json-exporter.nix b/nixos/modules/services/monitoring/prometheus/json-exporter.nix new file mode 100644 index 000000000000..ff3a137a0cf9 --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/json-exporter.nix @@ -0,0 +1,64 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.services.prometheus.jsonExporter; +in { + options = { + services.prometheus.jsonExporter = { + enable = mkEnableOption "prometheus JSON exporter"; + + url = mkOption { + type = types.str; + description = '' + URL to scrape JSON from. + ''; + }; + + configFile = mkOption { + type = types.path; + description = '' + Path to configuration file. + ''; + }; + + port = mkOption { + type = types.int; + default = 7979; + description = '' + Port to listen on. + ''; + }; + + extraFlags = mkOption { + type = types.listOf types.str; + default = []; + description = '' + Extra commandline options when launching the JSON exporter. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.services.prometheus-json-exporter = { + description = "Prometheus exporter for JSON over HTTP"; + unitConfig.Documentation = "https://github.com/kawamuray/prometheus-json-exporter"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + User = "nobody"; + Restart = "always"; + PrivateTmp = true; + WorkingDirectory = /tmp; + ExecStart = '' + ${pkgs.prometheus-json-exporter}/bin/prometheus-json-exporter \ + --port ${toString cfg.port} \ + ${cfg.url} ${cfg.configFile} \ + ${concatStringsSep " \\\n " cfg.extraFlags} + ''; + ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; + }; + }; + }; +} |