10 cfg = config.services.prometheus.exporters.rspamd;
21 mkFile = conf: pkgs.writeText "rspamd-exporter-config.yml" (builtins.toJSON conf);
23 generateConfig = extraLabels: {
24 modules.default.metrics =
27 name = "rspamd_${replaceStrings [ "[" "." " " "]" "\\" "'" ] [ "_" "_" "_" "" "" "" ] path}";
28 path = "{ .${path} }";
32 "actions['add\\ header']"
33 "actions['no\\ action']"
34 "actions['rewrite\\ subject']"
35 "actions['soft\\ reject']"
50 "shared_chunks_allocated"
57 name = "rspamd_statfiles";
59 path = "{.statfiles[*]}";
60 labels = recursiveUpdate {
65 revision = "{.revision}";
69 languages = "{.languages}";
79 extraLabels = mkOption {
80 type = types.attrsOf types.str;
82 host = config.networking.hostName;
84 defaultText = literalExpression "{ host = config.networking.hostName; }";
85 example = literalExpression ''
87 host = config.networking.hostName;
88 custom_label = "some_value";
91 description = "Set of labels added to each metric.";
94 serviceOpts.serviceConfig.ExecStart = ''
95 ${pkgs.prometheus-json-exporter}/bin/json_exporter \
96 --config.file ${mkFile (generateConfig cfg.extraLabels)} \
97 --web.listen-address "${cfg.listenAddress}:${toString cfg.port}" \
98 ${concatStringsSep " \\\n " cfg.extraFlags}
102 (mkRemovedOptionModule [ "url" ] ''
103 This option was removed. The URL of the rspamd metrics endpoint
104 must now be provided to the exporter by prometheus via the url
107 In prometheus a scrape URL would look like this:
109 http://some.rspamd-exporter.host:7980/probe?target=http://some.rspamd.host:11334/stat
111 For more information, take a look at the official documentation
112 (https://github.com/prometheus-community/json_exporter) of the json_exporter.
115 options.warnings = options.warnings;
116 options.assertions = options.assertions;