|
1 |
| -{ pkgs, ... }: |
| 1 | +{ config, pkgs, ... }: |
2 | 2 |
|
3 | 3 | 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 | + ]; |
9 | 30 | };
|
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 |
27 | 31 |
|
| 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 |
28 | 66 | {
|
29 | 67 | services.prometheus = {
|
30 | 68 | exporters.blackbox = {
|
|
37 | 75 | tcp.tls = true;
|
38 | 76 | http.headers.User-Agent = "blackbox-exporter";
|
39 | 77 | };
|
| 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 | + }; |
40 | 97 | }
|
41 | 98 | );
|
42 | 99 | };
|
43 | 100 |
|
44 | 101 | scrapeConfigs = [
|
45 |
| - (mkProbe "https_success" [ |
| 102 | + (mkHttpsProbe [ |
46 | 103 | "https://cache.nixos.org"
|
47 | 104 | "https://channels.nixos.org"
|
48 | 105 | "https://common-styles.nixos.org"
|
|
61 | 118 | "https://www.nixos.org"
|
62 | 119 | "https://tracker.security.nixos.org"
|
63 | 120 | ])
|
| 121 | + (mkSmtpStartTlsProbe [ |
| 122 | + "mail-test.nixos.org" |
| 123 | + ]) |
64 | 124 | ];
|
65 | 125 |
|
66 | 126 | ruleFiles = [
|
|
0 commit comments