blob: c088a3b08a8ea0e3bfd5f703bd8a7381ea5c4e51 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
{ pkgs, lib, config, ... }:
# from https://gist.github.com/globin/02496fd10a96a36f092a8e7ea0e6c7dd
{
networking = {
firewall.allowedTCPPorts = [
9090 # prometheus
9093 # alertmanager
];
};
services = {
nginx.virtualHosts = {
"prometheus.shack" = {
locations."/".proxyPass = "http://localhost:9090";
};
"alert.prometheus.shack" = {
locations."/".proxyPass = "http://localhost:9093";
};
};
prometheus = {
enable = true;
ruleFiles = lib.singleton (pkgs.writeText "prometheus-rules.yml" (builtins.toJSON {
groups = lib.singleton {
name = "mf-alerting-rules";
rules = import ./alert-rules.nix { inherit lib; };
};
}));
scrapeConfigs = [
{
job_name = "node";
scrape_interval = "10s";
static_configs = [
{
targets = [
"wolf.shack:9100"
];
labels = {
alias = "wolf.shack";
};
}
{
targets = [
"infra01.shack:9100"
];
labels = {
alias = "infra01.shack";
};
}
{
targets = [
"unifi.shack:9130"
];
labels = {
alias = "unifi.shack";
};
}
{
targets = [
"puyak.shack:9100" # puyak.shack
];
labels = {
alias = "puyak.shack";
};
}
{
targets = [
"phenylbutazon.shack:9100"
];
labels = {
alias = "phenylbutazon.shack";
};
}
{
targets = [
"ibuprofen.shack:9100"
];
labels = {
alias = "ibuprofen.shack";
};
}
];
}
{
job_name = "blackbox";
metrics_path = "/probe";
params.module = [ "icmp" ];
static_configs = [
{
targets = [
"google.com"
"wolf.shack"
"web.de"
"10.0.0.1"
"licht.shack"
];
}
];
relabel_configs = [
{
source_labels = ["__address__"];
target_label = "__param_target";
}
{
source_labels = ["__param_target"];
target_label = "instance";
}
{
target_label = "__address__";
replacement = "127.0.0.1:9115";
}
];
}
];
alertmanagers = [
{ scheme = "http";
path_prefix = "/";
static_configs = [ { targets = [ "localhost:9093" ]; } ];
}
];
alertmanager = {
enable = true;
listenAddress = "0.0.0.0";
configuration = {
"global" = {
"smtp_smarthost" = "smtp.example.com:587";
"smtp_from" = "alertmanager@example.com";
};
"route" = {
"group_by" = [ "alertname" "alias" ];
"group_wait" = "30s";
"group_interval" = "2m";
"repeat_interval" = "4h";
"receiver" = "team-admins";
};
"receivers" = [
{
"name" = "team-admins";
"email_configs" = [
{
"to" = "devnull@example.com";
"send_resolved" = true;
}
];
"webhook_configs" = [
{
"url" = "https://example.com/prometheus-alerts";
"send_resolved" = true;
}
];
}
];
};
};
};
};
}
|