main
nix 66 lines 1.66 KB
Raw
1 { pkgs, ... }:
2
3 {
4 services.prometheus = {
5 exporters.domain = {
6 enable = true;
7 listenAddress = "localhost";
8 };
9
10 scrapeConfigs = [
11 {
12 # https://github.com/caarlos0/domain_exporter#configuration
13 job_name = "domain";
14 metrics_path = "/probe";
15 relabel_configs = [
16 {
17 source_labels = [ "__address__" ];
18 target_label = "__param_target";
19 }
20 {
21 target_label = "__address__";
22 replacement = "localhost:9222";
23 }
24 ];
25 static_configs = [
26 {
27 targets = [
28 "nix.ci"
29 "nix.dev"
30 "nixos.org"
31 "ofborg.org"
32 ];
33 }
34 ];
35 }
36 ];
37
38 ruleFiles = [
39 (pkgs.writeText "domain-exporter.rules" (
40 builtins.toJSON {
41 groups = [
42 {
43 name = "domain";
44 rules = [
45 {
46 alert = "DomainExpiry";
47 expr = "domain_expiry_days != -1 and domain_expiry_days < 30";
48 for = "1h";
49 labels.severity = "warning";
50 annotations.summary = "Domain {{ $labels.domain }} will expire in less than 30 days";
51 }
52 {
53 alert = "DomainProbeFailure";
54 expr = "domain_probe_success == 0";
55 for = "1d";
56 labels.severity = "warning";
57 annotations.summary = "Domain {{ $labels.domain }} probe failing for more than 1 day.";
58 }
59 ];
60 }
61 ];
62 }
63 ))
64 ];
65 };
66 }