From c5ea578e3340638d8005b8aa72d3499e2ef17b11 Mon Sep 17 00:00:00 2001 From: Tom Herbers Date: Sun, 5 Apr 2026 22:40:56 +0200 Subject: [PATCH] nixos/prometheus-exporters/rspamd: drop Rspamd has an builtin /metrics endpoint which can be used instead. --- .../manual/release-notes/rl-2605.section.md | 2 + .../monitoring/prometheus/exporters.nix | 5 +- .../prometheus/exporters/rspamd.nix | 119 ------------------ nixos/tests/prometheus-exporters.nix | 20 --- 4 files changed, 6 insertions(+), 140 deletions(-) delete mode 100644 nixos/modules/services/monitoring/prometheus/exporters/rspamd.nix diff --git a/nixos/doc/manual/release-notes/rl-2605.section.md b/nixos/doc/manual/release-notes/rl-2605.section.md index 1765e878c59b..15cb68c98a0b 100644 --- a/nixos/doc/manual/release-notes/rl-2605.section.md +++ b/nixos/doc/manual/release-notes/rl-2605.section.md @@ -202,6 +202,8 @@ of pulling the upstream container image from Docker Hub. If you want the old beh - `rocmPackages_6` has been removed. `rocmPackages` has been updated to ROCm 7.x. Out of tree packages may rely on obsolete hipblas APIs or compile time constant warp size and need to be updated. +- `services.prometheus.exporters.rspamd` has been removed. It relied on the Rspamd /stat endpoint via the JSON exporter. You can use the Rspamd [/metrics](https://docs.rspamd.com/developers/protocol#controller-http-endpoints) endpoint directly instead. + - The Bash implementation of the `nixos-rebuild` program is removed. All switchable systems now use the Python rewrite. Any prior usage of `system.rebuild.enableNg` must now be removed. If you have any outstanding issues with the new implementation, please open an issue on GitHub. - `services.desktopManager.gnome` no longer installs the Geary e-mail client since it is not part of the GNOME [core applications](https://apps.gnome.org/) list. Geary's position in the default favorite apps section has been replaced by GNOME Text Editor. To keep it installed, add `programs.geary.enable = true;` to your configuration. diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix index d3298742772c..e602916426e8 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters.nix @@ -110,7 +110,6 @@ let "rasdaemon" "redis" "restic" - "rspamd" "rtl_433" "sabnzbd" "scaphandre" @@ -398,6 +397,10 @@ in (lib.mkRemovedOptionModule [ "tor" ] '' The Tor exporter has been removed, as it was broken and unmaintained. '') + (lib.mkRemovedOptionModule [ "rspamd" ] '' + The Rspamd exporter has been removed. You can use the Rspamd /metrics endpoint directly instead: + https://docs.rspamd.com/developers/protocol#controller-http-endpoints + '') ]; }; description = "Prometheus exporter configuration"; diff --git a/nixos/modules/services/monitoring/prometheus/exporters/rspamd.nix b/nixos/modules/services/monitoring/prometheus/exporters/rspamd.nix deleted file mode 100644 index de8ba9d676ae..000000000000 --- a/nixos/modules/services/monitoring/prometheus/exporters/rspamd.nix +++ /dev/null @@ -1,119 +0,0 @@ -{ - config, - lib, - pkgs, - options, - ... -}: - -let - cfg = config.services.prometheus.exporters.rspamd; - inherit (lib) - mkOption - types - replaceStrings - mkRemovedOptionModule - recursiveUpdate - concatStringsSep - literalExpression - ; - - mkFile = conf: pkgs.writeText "rspamd-exporter-config.yml" (builtins.toJSON conf); - - generateConfig = extraLabels: { - modules.default.metrics = - (map - (path: { - name = "rspamd_${replaceStrings [ "[" "." " " "]" "\\" "'" ] [ "_" "_" "_" "" "" "" ] path}"; - path = "{ .${path} }"; - labels = extraLabels; - }) - [ - "actions['add\\ header']" - "actions['no\\ action']" - "actions['rewrite\\ subject']" - "actions['soft\\ reject']" - "actions.greylist" - "actions.reject" - "bytes_allocated" - "chunks_allocated" - "chunks_freed" - "chunks_oversized" - "connections" - "control_connections" - "ham_count" - "learned" - "pools_allocated" - "pools_freed" - "read_only" - "scanned" - "shared_chunks_allocated" - "spam_count" - "total_learns" - ] - ) - ++ [ - { - name = "rspamd_statfiles"; - type = "object"; - path = "{.statfiles[*]}"; - labels = recursiveUpdate { - symbol = "{.symbol}"; - type = "{.type}"; - } extraLabels; - values = { - revision = "{.revision}"; - size = "{.size}"; - total = "{.total}"; - used = "{.used}"; - languages = "{.languages}"; - users = "{.users}"; - }; - } - ]; - }; -in -{ - port = 7980; - extraOpts = { - extraLabels = mkOption { - type = types.attrsOf types.str; - default = { - host = config.networking.hostName; - }; - defaultText = literalExpression "{ host = config.networking.hostName; }"; - example = literalExpression '' - { - host = config.networking.hostName; - custom_label = "some_value"; - } - ''; - description = "Set of labels added to each metric."; - }; - }; - serviceOpts.serviceConfig.ExecStart = '' - ${pkgs.prometheus-json-exporter}/bin/json_exporter \ - --config.file ${mkFile (generateConfig cfg.extraLabels)} \ - --web.listen-address "${cfg.listenAddress}:${toString cfg.port}" \ - ${concatStringsSep " \\\n " cfg.extraFlags} - ''; - - imports = [ - (mkRemovedOptionModule [ "url" ] '' - This option was removed. The URL of the rspamd metrics endpoint - must now be provided to the exporter by prometheus via the url - parameter `target'. - - In prometheus a scrape URL would look like this: - - http://some.rspamd-exporter.host:7980/probe?target=http://some.rspamd.host:11334/stat - - For more information, take a look at the official documentation - (https://github.com/prometheus-community/json_exporter) of the json_exporter. - '') - { - options.warnings = options.warnings; - options.assertions = options.assertions; - } - ]; -} diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix index 3a70bd554e1e..5f736f86fdf6 100644 --- a/nixos/tests/prometheus-exporters.nix +++ b/nixos/tests/prometheus-exporters.nix @@ -1540,26 +1540,6 @@ let ''; }; - rspamd = - { ... }: - { - exporterConfig = { - enable = true; - }; - metricProvider = { - services.rspamd.enable = true; - }; - exporterTest = '' - wait_for_unit("rspamd.service") - wait_for_unit("prometheus-rspamd-exporter.service") - wait_for_open_port(11334) - wait_for_open_port(7980) - wait_until_succeeds( - "curl -sSf 'localhost:7980/probe?target=http://localhost:11334/stat' | grep 'rspamd_scanned{host=\"rspamd\"} 0'" - ) - ''; - }; - rtl_433 = { ... }: {