blob: f5d2e7640a493b8e57d351e2bcb28609f8c31239 (
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
|
{ 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;
extraFlags = [
"-storage.local.retention 720h"
"-storage.local.series-file-shrink-ratio 0.3"
"-storage.local.memory-chunks 2097152"
"-storage.local.max-chunks-to-persist 1048576"
"-storage.local.index-cache-size.fingerprint-to-metric 2097152"
"-storage.local.index-cache-size.fingerprint-to-timerange 1048576"
"-storage.local.index-cache-size.label-name-to-label-values 2097152"
"-storage.local.index-cache-size.label-pair-to-fingerprints 41943040"
];
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 = [
"localhost:9100"
];
labels = {
alias = "wolf.shack";
};
}
{
targets = [
"localhost:9130"
];
labels = {
alias = "unifi.shack";
};
}
{
targets = [
"10.42.22.184:9100" # puyak.shack
];
labels = {
alias = "puyak.shack";
};
}
{
targets = [
"phenylbutazon.shack:9100"
];
labels = {
alias = "phenylbutazon.shack";
};
}
{
targets = [
"ibuprofen.shack:9100"
];
labels = {
alias = "ibuprofen.shack";
};
}
];
}
];
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;
}
];
}
];
};
};
};
};
}
|