diff options
| author | Finn Landweber <finn@landweber.xyz> | 2024-02-23 15:48:13 +0100 |
|---|---|---|
| committer | github-actions[bot] <github-actions[bot]@users.noreply.github.com> | 2024-07-17 17:09:01 +0000 |
| commit | d76378c5d5951edbd04e99f834fbea20d88045c8 (patch) | |
| tree | a1c6420c352fe8db6d88fcf74061d3df9ffd09af | |
| parent | prometheus-borgmatic-exporter: init at 0.2.5 (diff) | |
| download | nixpkgs-origin/backport-290452-to-release-24.05.tar.gz | |
added prometheus-borgmatic-exporter moduleorigin/backport-290452-to-release-24.05
(cherry picked from commit 0d58b75cba5cb091ae35916192deb33b1c2ad49d)
| -rw-r--r-- | nixos/modules/services/monitoring/prometheus/exporters.nix | 1 | ||||
| -rw-r--r-- | nixos/modules/services/monitoring/prometheus/exporters/borgmatic.nix | 34 | ||||
| -rw-r--r-- | nixos/tests/prometheus-exporters.nix | 20 |
3 files changed, 55 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters.nix b/nixos/modules/services/monitoring/prometheus/exporters.nix index 2dc12a221bf0..b257690a6059 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters.nix @@ -27,6 +27,7 @@ let "bird" "bitcoin" "blackbox" + "borgmatic" "buildkite-agent" "collectd" "dmarc" diff --git a/nixos/modules/services/monitoring/prometheus/exporters/borgmatic.nix b/nixos/modules/services/monitoring/prometheus/exporters/borgmatic.nix new file mode 100644 index 000000000000..573230c3afca --- /dev/null +++ b/nixos/modules/services/monitoring/prometheus/exporters/borgmatic.nix @@ -0,0 +1,34 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.services.prometheus.exporters.borgmatic; +in +{ + port = 9996; + extraOpts.configFile = lib.mkOption { + type = lib.types.path; + default = "/etc/borgmatic/config.yaml"; + description = '' + The path to the borgmatic config file + ''; + }; + + serviceOpts = { + serviceConfig = { + DynamicUser = false; + ProtectSystem = false; + ProtectHome = lib.mkForce false; + ExecStart = '' + ${pkgs.prometheus-borgmatic-exporter}/bin/borgmatic-exporter run \ + --port ${toString cfg.port} \ + --config ${toString cfg.configFile} \ + ${lib.concatMapStringsSep " " (f: lib.escapeShellArg f) cfg.extraFlags} + ''; + }; + }; +} diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix index 56569c4de2c8..637405834f55 100644 --- a/nixos/tests/prometheus-exporters.nix +++ b/nixos/tests/prometheus-exporters.nix @@ -177,6 +177,26 @@ let ''; }; + borgmatic = { + exporterConfig = { + enable = true; + user = "root"; + }; + metricProvider = { + services.borgmatic.enable = true; + services.borgmatic.settings.source_directories = [ "/home" ]; + services.borgmatic.settings.repositories = [ { label = "local"; path = "/var/backup"; } ]; + services.borgmatic.settings.keep_daily = 10; + }; + exporterTest = '' + succeed("borgmatic rcreate -e none") + succeed("borgmatic") + wait_for_unit("prometheus-borgmatic-exporter.service") + wait_for_open_port(9996) + succeed("curl -sSf localhost:9996/metrics | grep 'borg_total_backups{repository=\"/var/backup\"} 1'") + ''; + }; + collectd = { exporterConfig = { enable = true; |
