|
1 |
| -{ pkgs, ... }: |
2 |
| - |
3 |
| -let |
4 |
| - mkProbe = module: targets: { |
5 |
| - job_name = "blackbox-${module}"; |
6 |
| - metrics_path = "/probe"; |
7 |
| - params = { |
8 |
| - module = [ module ]; |
9 |
| - }; |
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 |
| 1 | +{ config, pkgs, ... }: |
27 | 2 |
|
28 | 3 | {
|
29 | 4 | services.prometheus = {
|
|
37 | 12 | tcp.tls = true;
|
38 | 13 | http.headers.User-Agent = "blackbox-exporter";
|
39 | 14 | };
|
| 15 | + |
| 16 | + # From https://github.com/prometheus/blackbox_exporter/blob/53e78c2b3535ecedfd072327885eeba2e9e51ea2/example.yml#L120-L133 |
| 17 | + modules.smtp_starttls = { |
| 18 | + prober = "tcp"; |
| 19 | + timeout = "5s"; |
| 20 | + tcp = { |
| 21 | + query_response = [ |
| 22 | + { expect = "^220 ([^ ]+) ESMTP (.+)$"; } |
| 23 | + { send = "EHLO prober\r"; } |
| 24 | + { expect = "^250-STARTTLS"; } |
| 25 | + { send = "STARTTLS\r"; } |
| 26 | + { expect = "^220"; } |
| 27 | + { starttls = true; } |
| 28 | + { send = "EHLO prober\r"; } |
| 29 | + { expect = "^250-AUTH"; } |
| 30 | + { send = "QUIT\r"; } |
| 31 | + ]; |
| 32 | + }; |
| 33 | + }; |
40 | 34 | }
|
41 | 35 | );
|
42 | 36 | };
|
43 | 37 |
|
44 | 38 | scrapeConfigs = [
|
45 |
| - (mkProbe "https_success" [ |
46 |
| - "https://cache.nixos.org" |
47 |
| - "https://channels.nixos.org" |
48 |
| - "https://common-styles.nixos.org" |
49 |
| - "https://discourse.nixos.org" |
50 |
| - "https://hydra.nixos.org" |
51 |
| - "https://mobile.nixos.org" |
52 |
| - "https://monitoring.nixos.org" |
53 |
| - "https://nixos.org" |
54 |
| - "https://planet.nixos.org" |
55 |
| - "https://releases.nixos.org" |
56 |
| - "https://status.nixos.org" |
57 |
| - "https://survey.nixos.org" |
58 |
| - "https://tarballs.nixos.org" |
59 |
| - "https://weekly.nixos.org" |
60 |
| - "https://wiki.nixos.org" |
61 |
| - "https://www.nixos.org" |
62 |
| - "https://tracker.security.nixos.org" |
63 |
| - ]) |
| 39 | + { |
| 40 | + job_name = "blackbox-https_success"; |
| 41 | + metrics_path = "/probe"; |
| 42 | + params = { |
| 43 | + module = [ "https_success" ]; |
| 44 | + }; |
| 45 | + static_configs = [ |
| 46 | + { |
| 47 | + targets = [ |
| 48 | + "https://cache.nixos.org" |
| 49 | + "https://channels.nixos.org" |
| 50 | + "https://common-styles.nixos.org" |
| 51 | + "https://discourse.nixos.org" |
| 52 | + "https://hydra.nixos.org" |
| 53 | + "https://mobile.nixos.org" |
| 54 | + "https://monitoring.nixos.org" |
| 55 | + "https://nixos.org" |
| 56 | + "https://planet.nixos.org" |
| 57 | + "https://releases.nixos.org" |
| 58 | + "https://status.nixos.org" |
| 59 | + "https://survey.nixos.org" |
| 60 | + "https://tarballs.nixos.org" |
| 61 | + "https://weekly.nixos.org" |
| 62 | + "https://wiki.nixos.org" |
| 63 | + "https://www.nixos.org" |
| 64 | + "https://tracker.security.nixos.org" |
| 65 | + ]; |
| 66 | + } |
| 67 | + ]; |
| 68 | + relabel_configs = [ |
| 69 | + { |
| 70 | + source_labels = [ "__address__" ]; |
| 71 | + target_label = "__param_target"; |
| 72 | + } |
| 73 | + { |
| 74 | + source_labels = [ "__param_target" ]; |
| 75 | + target_label = "instance"; |
| 76 | + } |
| 77 | + { |
| 78 | + target_label = "__address__"; |
| 79 | + replacement = "localhost:${toString config.services.prometheus.exporters.blackbox.port}"; |
| 80 | + } |
| 81 | + ]; |
| 82 | + } |
| 83 | + { |
| 84 | + job_name = "blackbox-smtp_starttls"; |
| 85 | + metrics_path = "/probe"; |
| 86 | + params = { |
| 87 | + module = [ "smtp_starttls" ]; |
| 88 | + }; |
| 89 | + dns_sd_configs = [ |
| 90 | + { |
| 91 | + names = [ |
| 92 | + "mail-test.nixos.org" |
| 93 | + ]; |
| 94 | + # TODO: this is blocked on https://github.com/NixOS/nixpkgs/pull/382617 |
| 95 | + # <<< type = "MX"; |
| 96 | + port = 25; |
| 97 | + } |
| 98 | + ]; |
| 99 | + relabel_configs = [ |
| 100 | + { |
| 101 | + source_labels = [ "__address__" ]; |
| 102 | + target_label = "__param_target"; |
| 103 | + } |
| 104 | + { |
| 105 | + source_labels = [ "__meta_dns_name" ]; |
| 106 | + target_label = "instance"; |
| 107 | + } |
| 108 | + { |
| 109 | + target_label = "__address__"; |
| 110 | + replacement = "localhost:${toString config.services.prometheus.exporters.blackbox.port}"; |
| 111 | + } |
| 112 | + ]; |
| 113 | + } |
64 | 114 | ];
|
65 | 115 |
|
66 | 116 | ruleFiles = [
|
|
0 commit comments