summary refs log tree commit diff
path: root/nixos/modules/services/monitoring/prometheus/exporters/json.nix
blob: bd0026b55f721228836b72d2bdc21cc54711c80d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{ config, lib, pkgs, options }:

with lib;

let
  cfg = config.services.prometheus.exporters.json;
in
{
  port = 7979;
  extraOpts = {
    url = mkOption {
      type = types.str;
      description = ''
        URL to scrape JSON from.
      '';
    };
    configFile = mkOption {
      type = types.path;
      description = ''
        Path to configuration file.
      '';
    };
    listenAddress = {}; # not used
  };
  serviceOpts = {
    serviceConfig = {
      ExecStart = ''
        ${pkgs.prometheus-json-exporter}/bin/prometheus-json-exporter \
          --port ${toString cfg.port} \
          ${cfg.url} ${escapeShellArg cfg.configFile} \
          ${concatStringsSep " \\\n  " cfg.extraFlags}
      '';
    };
  };
}