Enable metrics for zrepl
AFAICT, we don't have any monitoring/alerting set up for zrepl. Once this is deployed and working, I will add an alert so we get notified if replication hasn't succeeded recently.
Jeremy Fleischman committed
Apr 11, 2026 at 11:01 UTC
281bcf7a3f05902b47bc9ba0fef2c050a6ab72c5
3 files changed
+38
build/pluto/prometheus/default.nix
+1
@@ -21,6 +21,7 @@
21
./exporters/sql.nix
22
./exporters/up.nix
23
./exporters/zfs.nix
24
+ ./exporters/zrepl.nix
25
];
26
27
services.backup.includesZfsDatasets = [ "/var/lib/prometheus2" ];
build/pluto/prometheus/exporters/zrepl.nix
new
+21
@@ -0,0 +1,21 @@
1
+{ ... }:
2
+
3
+{
4
+ services.prometheus = {
5
+ scrapeConfigs = [
6
+ {
7
+ job_name = "zrepl";
8
+ static_configs = [
9
+ {
10
+ labels.role = "database";
11
+ targets = [
12
+ "titan.nixos.org:9811"
13
+ ];
14
+ }
15
+ ];
16
+ }
17
+ ];
18
+
19
+ # TODO: alert on `zrepl_replication_last_successful` being too long ago.
20
+ };
21
+}
build/titan/zrepl.nix
+16
@@ -4,6 +4,9 @@
4
...
5
}:
6
7
+let
8
+ metricsPort = 9811;
9
+in
10
{
11
age.secrets."zrepl-ssh-key" = {
12
file = ../secrets/zrepl-ssh-key.age;
@@ -106,6 +109,14 @@
109
];
110
};
111
112
+ # https://zrepl.github.io/configuration/monitoring.html
113
+ monitoring = [
114
+ {
115
+ type = "prometheus";
116
+ listen = ":${toString metricsPort}";
117
+ }
118
+ ];
119
+
120
jobs = [
121
# Covers 20240629+
122
(
@@ -132,4 +143,9 @@
143
];
144
};
145
};
146
+
147
+ networking.firewall.extraInputRules = ''
148
+ ip6 saddr $prometheus_inet6 tcp dport ${toString metricsPort} accept
149
+ ip saddr $prometheus_inet4 tcp dport ${toString metricsPort} accept
150
+ '';
151
}