summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flake.lock167
-rw-r--r--flake.nix9
-rw-r--r--hosts/vidhar/borg/default.nix20
-rw-r--r--hosts/vidhar/prometheus/default.nix12
4 files changed, 208 insertions, 0 deletions
diff --git a/flake.lock b/flake.lock
index ba4b2517..112d0c4a 100644
--- a/flake.lock
+++ b/flake.lock
@@ -122,6 +122,22 @@
122 "type": "github" 122 "type": "github"
123 } 123 }
124 }, 124 },
125 "flake-compat_4": {
126 "flake": false,
127 "locked": {
128 "lastModified": 1673956053,
129 "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
130 "owner": "edolstra",
131 "repo": "flake-compat",
132 "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
133 "type": "github"
134 },
135 "original": {
136 "owner": "edolstra",
137 "repo": "flake-compat",
138 "type": "github"
139 }
140 },
125 "flake-parts": { 141 "flake-parts": {
126 "inputs": { 142 "inputs": {
127 "nixpkgs-lib": "nixpkgs-lib" 143 "nixpkgs-lib": "nixpkgs-lib"
@@ -158,6 +174,24 @@
158 "type": "github" 174 "type": "github"
159 } 175 }
160 }, 176 },
177 "flake-parts_3": {
178 "inputs": {
179 "nixpkgs-lib": "nixpkgs-lib_3"
180 },
181 "locked": {
182 "lastModified": 1683560683,
183 "narHash": "sha256-XAygPMN5Xnk/W2c1aW0jyEa6lfMDZWlQgiNtmHXytPc=",
184 "owner": "hercules-ci",
185 "repo": "flake-parts",
186 "rev": "006c75898cf814ef9497252b022e91c946ba8e17",
187 "type": "github"
188 },
189 "original": {
190 "owner": "hercules-ci",
191 "repo": "flake-parts",
192 "type": "github"
193 }
194 },
161 "flake-registry": { 195 "flake-registry": {
162 "flake": false, 196 "flake": false,
163 "locked": { 197 "locked": {
@@ -223,6 +257,21 @@
223 "type": "github" 257 "type": "github"
224 } 258 }
225 }, 259 },
260 "flake-utils_4": {
261 "locked": {
262 "lastModified": 1667395993,
263 "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
264 "owner": "numtide",
265 "repo": "flake-utils",
266 "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
267 "type": "github"
268 },
269 "original": {
270 "owner": "numtide",
271 "repo": "flake-utils",
272 "type": "github"
273 }
274 },
226 "gitignore": { 275 "gitignore": {
227 "inputs": { 276 "inputs": {
228 "nixpkgs": [ 277 "nixpkgs": [
@@ -267,6 +316,28 @@
267 "type": "github" 316 "type": "github"
268 } 317 }
269 }, 318 },
319 "gitignore_3": {
320 "inputs": {
321 "nixpkgs": [
322 "prometheus-borg-exporter",
323 "pre-commit-hooks-nix",
324 "nixpkgs"
325 ]
326 },
327 "locked": {
328 "lastModified": 1660459072,
329 "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
330 "owner": "hercules-ci",
331 "repo": "gitignore.nix",
332 "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
333 "type": "github"
334 },
335 "original": {
336 "owner": "hercules-ci",
337 "repo": "gitignore.nix",
338 "type": "github"
339 }
340 },
270 "home-manager": { 341 "home-manager": {
271 "inputs": { 342 "inputs": {
272 "nixpkgs": [ 343 "nixpkgs": [
@@ -364,6 +435,24 @@
364 "type": "github" 435 "type": "github"
365 } 436 }
366 }, 437 },
438 "nixpkgs-lib_3": {
439 "locked": {
440 "dir": "lib",
441 "lastModified": 1682879489,
442 "narHash": "sha256-sASwo8gBt7JDnOOstnps90K1wxmVfyhsTPPNTGBPjjg=",
443 "owner": "NixOS",
444 "repo": "nixpkgs",
445 "rev": "da45bf6ec7bbcc5d1e14d3795c025199f28e0de0",
446 "type": "github"
447 },
448 "original": {
449 "dir": "lib",
450 "owner": "NixOS",
451 "ref": "nixos-unstable",
452 "repo": "nixpkgs",
453 "type": "github"
454 }
455 },
367 "nixpkgs-stable": { 456 "nixpkgs-stable": {
368 "locked": { 457 "locked": {
369 "lastModified": 1678614274, 458 "lastModified": 1678614274,
@@ -412,6 +501,22 @@
412 "type": "github" 501 "type": "github"
413 } 502 }
414 }, 503 },
504 "nixpkgs-stable_4": {
505 "locked": {
506 "lastModified": 1678872516,
507 "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=",
508 "owner": "NixOS",
509 "repo": "nixpkgs",
510 "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8",
511 "type": "github"
512 },
513 "original": {
514 "owner": "NixOS",
515 "ref": "nixos-22.11",
516 "repo": "nixpkgs",
517 "type": "github"
518 }
519 },
415 "nixpkgs_2": { 520 "nixpkgs_2": {
416 "locked": { 521 "locked": {
417 "lastModified": 1678898370, 522 "lastModified": 1678898370,
@@ -444,6 +549,22 @@
444 "type": "github" 549 "type": "github"
445 } 550 }
446 }, 551 },
552 "nixpkgs_4": {
553 "locked": {
554 "lastModified": 1681303793,
555 "narHash": "sha256-JEdQHsYuCfRL2PICHlOiH/2ue3DwoxUX7DJ6zZxZXFk=",
556 "owner": "NixOS",
557 "repo": "nixpkgs",
558 "rev": "fe2ecaf706a5907b5e54d979fbde4924d84b65fc",
559 "type": "github"
560 },
561 "original": {
562 "owner": "NixOS",
563 "ref": "nixos-unstable",
564 "repo": "nixpkgs",
565 "type": "github"
566 }
567 },
447 "nvfetcher": { 568 "nvfetcher": {
448 "inputs": { 569 "inputs": {
449 "flake-compat": [ 570 "flake-compat": [
@@ -515,6 +636,51 @@
515 "type": "github" 636 "type": "github"
516 } 637 }
517 }, 638 },
639 "pre-commit-hooks-nix_3": {
640 "inputs": {
641 "flake-compat": "flake-compat_4",
642 "flake-utils": "flake-utils_4",
643 "gitignore": "gitignore_3",
644 "nixpkgs": "nixpkgs_4",
645 "nixpkgs-stable": "nixpkgs-stable_4"
646 },
647 "locked": {
648 "lastModified": 1685361114,
649 "narHash": "sha256-4RjrlSb+OO+e1nzTExKW58o3WRwVGpXwj97iCta8aj4=",
650 "owner": "cachix",
651 "repo": "pre-commit-hooks.nix",
652 "rev": "ca2fdbf3edda2a38140184da6381d49f8206eaf4",
653 "type": "github"
654 },
655 "original": {
656 "owner": "cachix",
657 "repo": "pre-commit-hooks.nix",
658 "type": "github"
659 }
660 },
661 "prometheus-borg-exporter": {
662 "inputs": {
663 "flake-parts": "flake-parts_3",
664 "nixpkgs": [
665 "nixpkgs"
666 ],
667 "pre-commit-hooks-nix": "pre-commit-hooks-nix_3"
668 },
669 "locked": {
670 "lastModified": 1685389961,
671 "narHash": "sha256-D01xvx8trgelAM5D/1rZ9/s2Wqm3LDBfH29VWGeYu5o=",
672 "owner": "gkleen",
673 "repo": "prometheus-borg-exporter",
674 "rev": "153c3864761d4741dc72e360f96de8c169834b81",
675 "type": "gitlab"
676 },
677 "original": {
678 "owner": "gkleen",
679 "ref": "main",
680 "repo": "prometheus-borg-exporter",
681 "type": "gitlab"
682 }
683 },
518 "root": { 684 "root": {
519 "inputs": { 685 "inputs": {
520 "backup-utils": "backup-utils", 686 "backup-utils": "backup-utils",
@@ -528,6 +694,7 @@
528 "nixpkgs": "nixpkgs_3", 694 "nixpkgs": "nixpkgs_3",
529 "nixpkgs-stable": "nixpkgs-stable_3", 695 "nixpkgs-stable": "nixpkgs-stable_3",
530 "nvfetcher": "nvfetcher", 696 "nvfetcher": "nvfetcher",
697 "prometheus-borg-exporter": "prometheus-borg-exporter",
531 "sops-nix": "sops-nix" 698 "sops-nix": "sops-nix"
532 } 699 }
533 }, 700 },
diff --git a/flake.nix b/flake.nix
index db77a814..d51cd532 100644
--- a/flake.nix
+++ b/flake.nix
@@ -106,6 +106,15 @@
106 nixpkgs.follows = "nixpkgs"; 106 nixpkgs.follows = "nixpkgs";
107 }; 107 };
108 }; 108 };
109 prometheus-borg-exporter = {
110 type = "gitlab";
111 owner = "gkleen";
112 repo = "prometheus-borg-exporter";
113 ref = "main";
114 inputs = {
115 nixpkgs.follows = "nixpkgs";
116 };
117 };
109 }; 118 };
110 119
111 outputs = { self, nixpkgs, home-manager, sops-nix, deploy-rs, nvfetcher, ... }@inputs: 120 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
48 48
49 baseDir = "/srv/backup/borg"; 49 baseDir = "/srv/backup/borg";
50in { 50in {
51 imports = with flakeInputs; [
52 prometheus-borg-exporter.nixosModules.default
53 ];
54
51 config = { 55 config = {
52 services.borgsnap = { 56 services.borgsnap = {
53 enable = true; 57 enable = true;
@@ -86,6 +90,22 @@ in {
86 }; 90 };
87 }; 91 };
88 92
93 services.prometheus-borg-exporter = {
94 enable = true;
95 gateway = "localhost:9091";
96 target = "yggdrasil.borgbase:repo";
97 inherit sshConfig;
98 keyfile = config.sops.secrets."yggdrasil.borgkey".path;
99
100 config = {
101 job = "yggdrasil.borgbase";
102 groups = [
103 { regex = "(?P<prefix>yggdrasil\.(surtr|vidhar|niflheim\.ymir))\.(?P<target>.+)-[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}"; }
104 ];
105 };
106 };
107
108
89 # systemd.services."check-borg@${utils.escapeSystemdPath "${baseDir}/jotnar"}" = checkBorgUnit; 109 # systemd.services."check-borg@${utils.escapeSystemdPath "${baseDir}/jotnar"}" = checkBorgUnit;
90 # systemd.services."check-borg@${utils.escapeSystemdPath "yggdrasil.borgbase:repo"}" = recursiveUpdate checkBorgUnit { 110 # systemd.services."check-borg@${utils.escapeSystemdPath "yggdrasil.borgbase:repo"}" = recursiveUpdate checkBorgUnit {
91 # serviceConfig = { 111 # 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 {
241 ]; 241 ];
242 scrape_interval = "5s"; 242 scrape_interval = "5s";
243 } 243 }
244 { job_name = "pushgateway";
245 honor_labels = true;
246 static_configs = [
247 { targets = ["localhost:9091"];}
248 ];
249 scrape_interval = "5s";
250 }
244 ]; 251 ];
245 252
246 rules = [ 253 rules = [
@@ -288,7 +295,12 @@ in {
288 ]; 295 ];
289 }) 296 })
290 ]; 297 ];
298
299 pushgateway = {
300 enable = true;
301 };
291 }; 302 };
303
292 users.users.${config.services.prometheus.exporters.unbound.user} = { 304 users.users.${config.services.prometheus.exporters.unbound.user} = {
293 description = "Prometheus unbound exporter service user"; 305 description = "Prometheus unbound exporter service user";
294 isSystemUser = true; 306 isSystemUser = true;