lol

prometheus module: add jsonExporter

authored by

Corbin and committed by
Robin Gloster
bd45d5fe 1e5de5fc

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