summary refs log tree commit diff
path: root/nixos/modules/services/monitoring/prometheus/exporters/flow.nix
blob: b85e5461f2180daa42ef5512e3faa7a3b3f8dbf6 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{ config, lib, pkgs, options }:

with lib;

let
  cfg = config.services.prometheus.exporters.flow;
in {
  port = 9590;
  extraOpts = {
    brokers = mkOption {
      type = types.listOf types.str;
      example = literalExpression ''[ "kafka.example.org:19092" ]'';
      description = "List of Kafka brokers to connect to.";
    };

    asn = mkOption {
      type = types.ints.positive;
      example = 65542;
      description = "The ASN being monitored.";
    };

    partitions = mkOption {
      type = types.listOf types.int;
      default = [];
      description = ''
        The number of the partitions to consume, none means all.
      '';
    };

    topic = mkOption {
      type = types.str;
      example = "pmacct.acct";
      description = "The Kafka topic to consume from.";
    };
  };

  serviceOpts = {
    serviceConfig = {
      DynamicUser = true;
      ExecStart = ''
        ${pkgs.prometheus-flow-exporter}/bin/flow-exporter \
          -asn ${toString cfg.asn} \
          -topic ${cfg.topic} \
          -brokers ${concatStringsSep "," cfg.brokers} \
          ${optionalString (cfg.partitions != []) "-partitions ${concatStringsSep "," cfg.partitions}"} \
          -addr ${cfg.listenAddress}:${toString cfg.port} ${concatStringsSep " " cfg.extraFlags}
      '';
    };
  };
}