|
1 |
| -{ pkgs, ... }: |
| 1 | +{ config, pkgs, ... }: |
2 | 2 |
|
3 | 3 | let
|
4 |
| - mkProbe = module: targets: { |
| 4 | + mkStaticProbe = module: targets: { |
5 | 5 | job_name = "blackbox-${module}";
|
6 | 6 | metrics_path = "/probe";
|
7 | 7 | params = {
|
|
19 | 19 | }
|
20 | 20 | {
|
21 | 21 | target_label = "__address__";
|
22 |
| - replacement = "localhost:9115"; |
| 22 | + replacement = "localhost:${toString config.services.prometheus.exporters.blackbox.port}"; |
23 | 23 | }
|
24 | 24 | ];
|
25 | 25 | };
|
26 |
| -in |
27 | 26 |
|
| 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 |
28 | 52 | {
|
29 | 53 | services.prometheus = {
|
30 | 54 | exporters.blackbox = {
|
|
37 | 61 | tcp.tls = true;
|
38 | 62 | http.headers.User-Agent = "blackbox-exporter";
|
39 | 63 | };
|
| 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 | + }; |
40 | 83 | }
|
41 | 84 | );
|
42 | 85 | };
|
43 | 86 |
|
44 | 87 | scrapeConfigs = [
|
45 |
| - (mkProbe "https_success" [ |
| 88 | + (mkStaticProbe "https_success" [ |
46 | 89 | "https://cache.nixos.org"
|
47 | 90 | "https://channels.nixos.org"
|
48 | 91 | "https://common-styles.nixos.org"
|
|
61 | 104 | "https://www.nixos.org"
|
62 | 105 | "https://tracker.security.nixos.org"
|
63 | 106 | ])
|
| 107 | + (mkDnsSdProbe "smtp_starttls" { |
| 108 | + names = [ |
| 109 | + "mail-test.nixos.org" |
| 110 | + ]; |
| 111 | + type = "MX"; |
| 112 | + port = 25; |
| 113 | + }) |
64 | 114 | ];
|
65 | 115 |
|
66 | 116 | ruleFiles = [
|
|
0 commit comments