1{ 2 config, 3 lib, 4 pkgs, 5 options, 6 ... 7}: 8 9let 10 cfg = config.services.prometheus.exporters.json; 11 inherit (lib) 12 mkOption 13 types 14 escapeShellArg 15 concatStringsSep 16 mkRemovedOptionModule 17 ; 18in 19{ 20 port = 7979; 21 extraOpts = { 22 configFile = mkOption { 23 type = types.path; 24 description = '' 25 Path to configuration file. 26 ''; 27 }; 28 }; 29 serviceOpts = { 30 serviceConfig = { 31 ExecStart = '' 32 ${pkgs.prometheus-json-exporter}/bin/json_exporter \ 33 --config.file ${escapeShellArg cfg.configFile} \ 34 --web.listen-address="${cfg.listenAddress}:${toString cfg.port}" \ 35 ${concatStringsSep " \\\n " cfg.extraFlags} 36 ''; 37 }; 38 }; 39 imports = [ 40 (mkRemovedOptionModule [ "url" ] '' 41 This option was removed. The URL of the endpoint serving JSON 42 must now be provided to the exporter by prometheus via the url 43 parameter `target'. 44 45 In prometheus a scrape URL would look like this: 46 47 http://some.json-exporter.host:7979/probe?target=https://example.com/some/json/endpoint 48 49 For more information, take a look at the official documentation 50 (https://github.com/prometheus-community/json_exporter) of the json_exporter. 51 '') 52 ({ 53 options.warnings = options.warnings; 54 options.assertions = options.assertions; 55 }) 56 ]; 57}