From 52e32157c076a5c2999a49de8b524f50e35c665d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Mon, 29 May 2023 22:10:27 +0200 Subject: prometheus-borg-exporter --- flake.lock | 167 ++++++++++++++++++++++++++++++++++++ flake.nix | 9 ++ hosts/vidhar/borg/default.nix | 20 +++++ hosts/vidhar/prometheus/default.nix | 12 +++ 4 files changed, 208 insertions(+) diff --git a/flake.lock b/flake.lock index ba4b2517..112d0c4a 100644 --- a/flake.lock +++ b/flake.lock @@ -122,6 +122,22 @@ "type": "github" } }, + "flake-compat_4": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -158,6 +174,24 @@ "type": "github" } }, + "flake-parts_3": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib_3" + }, + "locked": { + "lastModified": 1683560683, + "narHash": "sha256-XAygPMN5Xnk/W2c1aW0jyEa6lfMDZWlQgiNtmHXytPc=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "006c75898cf814ef9497252b022e91c946ba8e17", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-registry": { "flake": false, "locked": { @@ -223,6 +257,21 @@ "type": "github" } }, + "flake-utils_4": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -267,6 +316,28 @@ "type": "github" } }, + "gitignore_3": { + "inputs": { + "nixpkgs": [ + "prometheus-borg-exporter", + "pre-commit-hooks-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -364,6 +435,24 @@ "type": "github" } }, + "nixpkgs-lib_3": { + "locked": { + "dir": "lib", + "lastModified": 1682879489, + "narHash": "sha256-sASwo8gBt7JDnOOstnps90K1wxmVfyhsTPPNTGBPjjg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "da45bf6ec7bbcc5d1e14d3795c025199f28e0de0", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs-stable": { "locked": { "lastModified": 1678614274, @@ -412,6 +501,22 @@ "type": "github" } }, + "nixpkgs-stable_4": { + "locked": { + "lastModified": 1678872516, + "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, "nixpkgs_2": { "locked": { "lastModified": 1678898370, @@ -444,6 +549,22 @@ "type": "github" } }, + "nixpkgs_4": { + "locked": { + "lastModified": 1681303793, + "narHash": "sha256-JEdQHsYuCfRL2PICHlOiH/2ue3DwoxUX7DJ6zZxZXFk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "fe2ecaf706a5907b5e54d979fbde4924d84b65fc", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "nvfetcher": { "inputs": { "flake-compat": [ @@ -515,6 +636,51 @@ "type": "github" } }, + "pre-commit-hooks-nix_3": { + "inputs": { + "flake-compat": "flake-compat_4", + "flake-utils": "flake-utils_4", + "gitignore": "gitignore_3", + "nixpkgs": "nixpkgs_4", + "nixpkgs-stable": "nixpkgs-stable_4" + }, + "locked": { + "lastModified": 1685361114, + "narHash": "sha256-4RjrlSb+OO+e1nzTExKW58o3WRwVGpXwj97iCta8aj4=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "ca2fdbf3edda2a38140184da6381d49f8206eaf4", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "prometheus-borg-exporter": { + "inputs": { + "flake-parts": "flake-parts_3", + "nixpkgs": [ + "nixpkgs" + ], + "pre-commit-hooks-nix": "pre-commit-hooks-nix_3" + }, + "locked": { + "lastModified": 1685389961, + "narHash": "sha256-D01xvx8trgelAM5D/1rZ9/s2Wqm3LDBfH29VWGeYu5o=", + "owner": "gkleen", + "repo": "prometheus-borg-exporter", + "rev": "153c3864761d4741dc72e360f96de8c169834b81", + "type": "gitlab" + }, + "original": { + "owner": "gkleen", + "ref": "main", + "repo": "prometheus-borg-exporter", + "type": "gitlab" + } + }, "root": { "inputs": { "backup-utils": "backup-utils", @@ -528,6 +694,7 @@ "nixpkgs": "nixpkgs_3", "nixpkgs-stable": "nixpkgs-stable_3", "nvfetcher": "nvfetcher", + "prometheus-borg-exporter": "prometheus-borg-exporter", "sops-nix": "sops-nix" } }, diff --git a/flake.nix b/flake.nix index db77a814..d51cd532 100644 --- a/flake.nix +++ b/flake.nix @@ -106,6 +106,15 @@ nixpkgs.follows = "nixpkgs"; }; }; + prometheus-borg-exporter = { + type = "gitlab"; + owner = "gkleen"; + repo = "prometheus-borg-exporter"; + ref = "main"; + inputs = { + nixpkgs.follows = "nixpkgs"; + }; + }; }; outputs = { self, nixpkgs, home-manager, sops-nix, deploy-rs, nvfetcher, ... }@inputs: diff --git a/hosts/vidhar/borg/default.nix b/hosts/vidhar/borg/default.nix index 922cbf02..c97c4216 100644 --- a/hosts/vidhar/borg/default.nix +++ b/hosts/vidhar/borg/default.nix @@ -48,6 +48,10 @@ let baseDir = "/srv/backup/borg"; in { + imports = with flakeInputs; [ + prometheus-borg-exporter.nixosModules.default + ]; + config = { services.borgsnap = { enable = true; @@ -86,6 +90,22 @@ in { }; }; + services.prometheus-borg-exporter = { + enable = true; + gateway = "localhost:9091"; + target = "yggdrasil.borgbase:repo"; + inherit sshConfig; + keyfile = config.sops.secrets."yggdrasil.borgkey".path; + + config = { + job = "yggdrasil.borgbase"; + groups = [ + { regex = "(?Pyggdrasil\.(surtr|vidhar|niflheim\.ymir))\.(?P.+)-[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}"; } + ]; + }; + }; + + # systemd.services."check-borg@${utils.escapeSystemdPath "${baseDir}/jotnar"}" = checkBorgUnit; # systemd.services."check-borg@${utils.escapeSystemdPath "yggdrasil.borgbase:repo"}" = recursiveUpdate checkBorgUnit { # serviceConfig = { diff --git a/hosts/vidhar/prometheus/default.nix b/hosts/vidhar/prometheus/default.nix index 133ddbbc..d6d29c17 100644 --- a/hosts/vidhar/prometheus/default.nix +++ b/hosts/vidhar/prometheus/default.nix @@ -241,6 +241,13 @@ in { ]; scrape_interval = "5s"; } + { job_name = "pushgateway"; + honor_labels = true; + static_configs = [ + { targets = ["localhost:9091"];} + ]; + scrape_interval = "5s"; + } ]; rules = [ @@ -288,7 +295,12 @@ in { ]; }) ]; + + pushgateway = { + enable = true; + }; }; + users.users.${config.services.prometheus.exporters.unbound.user} = { description = "Prometheus unbound exporter service user"; isSystemUser = true; -- cgit v1.2.3