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