1 { config, lib, pkgs, options, ... }:
4 cfg = config.services.prometheus.exporters.mongodb;
21 default = "mongodb://localhost:27017/test";
22 example = "mongodb://localhost:27017/test";
23 description = "MongoDB URI to connect to.";
25 collStats = mkOption {
26 type = types.listOf types.str;
28 example = [ "db1.coll1" "db2" ];
30 List of comma separared databases.collections to get $collStats
33 indexStats = mkOption {
34 type = types.listOf types.str;
36 example = [ "db1.coll1" "db2" ];
38 List of comma separared databases.collections to get $indexStats
41 collector = mkOption {
42 type = types.listOf types.str;
44 example = [ "diagnosticdata" "replicasetstatus" "dbstats" "topmetrics" "currentopmetrics" "indexstats" "dbstats" "profile" ];
45 description = "Enabled collectors";
47 collectAll = mkOption {
51 Enable all collectors. Same as specifying all --collector.<name>
54 telemetryPath = mkOption {
58 description = "Metrics expose path";
63 RuntimeDirectory = "prometheus-mongodb-exporter";
65 ${getExe pkgs.prometheus-mongodb-exporter} \
66 --mongodb.uri="${cfg.uri}" \
67 ${if cfg.collectAll then "--collect-all" else concatMapStringsSep " " (x: "--collect.${x}") cfg.collector} \
68 ${optionalString (length cfg.collStats > 0) "--mongodb.collstats-colls=${concatStringsSep "," cfg.collStats}"} \
69 ${optionalString (length cfg.indexStats > 0) "--mongodb.indexstats-colls=${concatStringsSep "," cfg.indexStats}"} \
70 --web.listen-address="${cfg.listenAddress}:${toString cfg.port}" \
71 --web.telemetry-path="${cfg.telemetryPath}" \
72 ${escapeShellArgs cfg.extraFlags}