1 { config, lib, pkgs, options, ... }:
4 cfg = config.services.prometheus.exporters.rspamd;
16 pkgs.writeText "rspamd-exporter-config.yml" (builtins.toJSON conf);
18 generateConfig = extraLabels: {
19 modules.default.metrics = (map (path: {
20 name = "rspamd_${replaceStrings [ "[" "." " " "]" "\\" "'" ] [ "_" "_" "_" "" "" "" ] path}";
21 path = "{ .${path} }";
24 "actions['add\\ header']"
25 "actions['no\\ action']"
26 "actions['rewrite\\ subject']"
27 "actions['soft\\ reject']"
42 "shared_chunks_allocated"
46 name = "rspamd_statfiles";
48 path = "{.statfiles[*]}";
49 labels = recursiveUpdate {
54 revision = "{.revision}";
58 languages = "{.languages}";
67 extraLabels = mkOption {
68 type = types.attrsOf types.str;
70 host = config.networking.hostName;
72 defaultText = literalExpression "{ host = config.networking.hostName; }";
73 example = literalExpression ''
75 host = config.networking.hostName;
76 custom_label = "some_value";
79 description = "Set of labels added to each metric.";
82 serviceOpts.serviceConfig.ExecStart = ''
83 ${pkgs.prometheus-json-exporter}/bin/json_exporter \
84 --config.file ${mkFile (generateConfig cfg.extraLabels)} \
85 --web.listen-address "${cfg.listenAddress}:${toString cfg.port}" \
86 ${concatStringsSep " \\\n " cfg.extraFlags}
90 (mkRemovedOptionModule [ "url" ] ''
91 This option was removed. The URL of the rspamd metrics endpoint
92 must now be provided to the exporter by prometheus via the url
95 In prometheus a scrape URL would look like this:
97 http://some.rspamd-exporter.host:7980/probe?target=http://some.rspamd.host:11334/stat
99 For more information, take a look at the official documentation
100 (https://github.com/prometheus-community/json_exporter) of the json_exporter.
102 ({ options.warnings = options.warnings; options.assertions = options.assertions; })