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