1{ config, lib, pkgs, options }: 2 3with lib; 4 5let 6 cfg = config.services.prometheus.exporters.flow; 7in { 8 port = 9590; 9 extraOpts = { 10 brokers = mkOption { 11 type = types.listOf types.str; 12 example = literalExpression ''[ "kafka.example.org:19092" ]''; 13 description = lib.mdDoc "List of Kafka brokers to connect to."; 14 }; 15 16 asn = mkOption { 17 type = types.ints.positive; 18 example = 65542; 19 description = lib.mdDoc "The ASN being monitored."; 20 }; 21 22 partitions = mkOption { 23 type = types.listOf types.int; 24 default = []; 25 description = lib.mdDoc '' 26 The number of the partitions to consume, none means all. 27 ''; 28 }; 29 30 topic = mkOption { 31 type = types.str; 32 example = "pmacct.acct"; 33 description = lib.mdDoc "The Kafka topic to consume from."; 34 }; 35 }; 36 37 serviceOpts = { 38 serviceConfig = { 39 DynamicUser = true; 40 ExecStart = '' 41 ${pkgs.prometheus-flow-exporter}/bin/flow-exporter \ 42 -asn ${toString cfg.asn} \ 43 -topic ${cfg.topic} \ 44 -brokers ${concatStringsSep "," cfg.brokers} \ 45 ${optionalString (cfg.partitions != []) "-partitions ${concatStringsSep "," cfg.partitions}"} \ 46 -addr ${cfg.listenAddress}:${toString cfg.port} ${concatStringsSep " " cfg.extraFlags} 47 ''; 48 }; 49 }; 50}