Skip to content

Commit ea244b0

Browse files
committed
Add a blackbox monitor of our mailserver
I re-locked in order to pull in <NixOS/nixpkgs#383081> To avoid potential alerting noise: I'll wait until this is deployed and succeeding before declaring an additional alert. refs: NixOS#485
1 parent 82f5194 commit ea244b0

File tree

2 files changed

+64
-14
lines changed

2 files changed

+64
-14
lines changed

build/flake.lock

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/pluto/prometheus/exporters/blackbox.nix

+55-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
{ pkgs, ... }:
1+
{ config, pkgs, ... }:
22

33
let
4-
mkProbe = module: targets: {
4+
mkStaticProbe = module: targets: {
55
job_name = "blackbox-${module}";
66
metrics_path = "/probe";
77
params = {
@@ -19,12 +19,36 @@ let
1919
}
2020
{
2121
target_label = "__address__";
22-
replacement = "localhost:9115";
22+
replacement = "localhost:${toString config.services.prometheus.exporters.blackbox.port}";
2323
}
2424
];
2525
};
26-
in
2726

27+
mkDnsSdProbe = module: dns_sd_config: {
28+
job_name = "blackbox-${module}";
29+
metrics_path = "/probe";
30+
params = {
31+
module = [ module ];
32+
};
33+
dns_sd_configs = [
34+
dns_sd_config
35+
];
36+
relabel_configs = [
37+
{
38+
source_labels = [ "__address__" ];
39+
target_label = "__param_target";
40+
}
41+
{
42+
source_labels = [ "__meta_dns_name" ];
43+
target_label = "instance";
44+
}
45+
{
46+
target_label = "__address__";
47+
replacement = "localhost:${toString config.services.prometheus.exporters.blackbox.port}";
48+
}
49+
];
50+
};
51+
in
2852
{
2953
services.prometheus = {
3054
exporters.blackbox = {
@@ -37,12 +61,31 @@ in
3761
tcp.tls = true;
3862
http.headers.User-Agent = "blackbox-exporter";
3963
};
64+
65+
# From https://github.com/prometheus/blackbox_exporter/blob/53e78c2b3535ecedfd072327885eeba2e9e51ea2/example.yml#L120-L133
66+
modules.smtp_starttls = {
67+
prober = "tcp";
68+
timeout = "5s";
69+
tcp = {
70+
query_response = [
71+
{ expect = "^220 ([^ ]+) ESMTP (.+)$"; }
72+
{ send = "EHLO prober\r"; }
73+
{ expect = "^250-STARTTLS"; }
74+
{ send = "STARTTLS\r"; }
75+
{ expect = "^220"; }
76+
{ starttls = true; }
77+
{ send = "EHLO prober\r"; }
78+
{ expect = "^250-AUTH"; }
79+
{ send = "QUIT\r"; }
80+
];
81+
};
82+
};
4083
}
4184
);
4285
};
4386

4487
scrapeConfigs = [
45-
(mkProbe "https_success" [
88+
(mkStaticProbe "https_success" [
4689
"https://cache.nixos.org"
4790
"https://channels.nixos.org"
4891
"https://common-styles.nixos.org"
@@ -61,6 +104,13 @@ in
61104
"https://www.nixos.org"
62105
"https://tracker.security.nixos.org"
63106
])
107+
(mkDnsSdProbe "smtp_starttls" {
108+
names = [
109+
"mail-test.nixos.org"
110+
];
111+
type = "MX";
112+
port = 25;
113+
})
64114
];
65115

66116
ruleFiles = [

0 commit comments

Comments
 (0)