Skip to content

Commit 0ecb2b8

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 0ecb2b8

File tree

2 files changed

+93
-33
lines changed

2 files changed

+93
-33
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

+84-24
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,68 @@
1-
{ pkgs, ... }:
1+
{ config, pkgs, ... }:
22

33
let
4-
mkProbe = module: targets: {
5-
job_name = "blackbox-${module}";
6-
metrics_path = "/probe";
7-
params = {
8-
module = [ module ];
4+
mkHttpsProbe =
5+
targets:
6+
let
7+
module = "https_success";
8+
in
9+
{
10+
job_name = "blackbox-${module}";
11+
metrics_path = "/probe";
12+
params = {
13+
module = [ module ];
14+
};
15+
static_configs = [ { inherit targets; } ];
16+
relabel_configs = [
17+
{
18+
source_labels = [ "__address__" ];
19+
target_label = "__param_target";
20+
}
21+
{
22+
source_labels = [ "__param_target" ];
23+
target_label = "instance";
24+
}
25+
{
26+
target_label = "__address__";
27+
replacement = "localhost:${toString config.services.prometheus.exporters.blackbox.port}";
28+
}
29+
];
930
};
10-
static_configs = [ { inherit targets; } ];
11-
relabel_configs = [
12-
{
13-
source_labels = [ "__address__" ];
14-
target_label = "__param_target";
15-
}
16-
{
17-
source_labels = [ "__param_target" ];
18-
target_label = "instance";
19-
}
20-
{
21-
target_label = "__address__";
22-
replacement = "localhost:9115";
23-
}
24-
];
25-
};
26-
in
2731

32+
mkSmtpStartTlsProbe =
33+
names:
34+
let
35+
module = "smtp_starttls";
36+
in
37+
{
38+
job_name = "blackbox-${module}";
39+
metrics_path = "/probe";
40+
params = {
41+
module = [ module ];
42+
};
43+
dns_sd_configs = [
44+
{
45+
inherit names;
46+
type = "MX";
47+
port = 25;
48+
}
49+
];
50+
relabel_configs = [
51+
{
52+
source_labels = [ "__address__" ];
53+
target_label = "__param_target";
54+
}
55+
{
56+
source_labels = [ "__meta_dns_name" ];
57+
target_label = "instance";
58+
}
59+
{
60+
target_label = "__address__";
61+
replacement = "localhost:${toString config.services.prometheus.exporters.blackbox.port}";
62+
}
63+
];
64+
};
65+
in
2866
{
2967
services.prometheus = {
3068
exporters.blackbox = {
@@ -37,12 +75,31 @@ in
3775
tcp.tls = true;
3876
http.headers.User-Agent = "blackbox-exporter";
3977
};
78+
79+
# From https://github.com/prometheus/blackbox_exporter/blob/53e78c2b3535ecedfd072327885eeba2e9e51ea2/example.yml#L120-L133
80+
modules.smtp_starttls = {
81+
prober = "tcp";
82+
timeout = "5s";
83+
tcp = {
84+
query_response = [
85+
{ expect = "^220 ([^ ]+) ESMTP (.+)$"; }
86+
{ send = "EHLO prober\r"; }
87+
{ expect = "^250-STARTTLS"; }
88+
{ send = "STARTTLS\r"; }
89+
{ expect = "^220"; }
90+
{ starttls = true; }
91+
{ send = "EHLO prober\r"; }
92+
{ expect = "^250-AUTH"; }
93+
{ send = "QUIT\r"; }
94+
];
95+
};
96+
};
4097
}
4198
);
4299
};
43100

44101
scrapeConfigs = [
45-
(mkProbe "https_success" [
102+
(mkHttpsProbe [
46103
"https://cache.nixos.org"
47104
"https://channels.nixos.org"
48105
"https://common-styles.nixos.org"
@@ -61,6 +118,9 @@ in
61118
"https://www.nixos.org"
62119
"https://tracker.security.nixos.org"
63120
])
121+
(mkSmtpStartTlsProbe [
122+
"mail-test.nixos.org"
123+
])
64124
];
65125

66126
ruleFiles = [

0 commit comments

Comments
 (0)