2019-06-20 20:21:56 +00:00
|
|
|
{ pkgs, lib, config, ... }:
|
|
|
|
# from https://gist.github.com/globin/02496fd10a96a36f092a8e7ea0e6c7dd
|
|
|
|
{
|
2020-09-14 09:11:58 +00:00
|
|
|
imports = [
|
|
|
|
./alert-rules.nix
|
|
|
|
];
|
2019-06-20 20:21:56 +00:00
|
|
|
networking = {
|
|
|
|
firewall.allowedTCPPorts = [
|
|
|
|
9090 # prometheus
|
|
|
|
9093 # alertmanager
|
|
|
|
];
|
|
|
|
};
|
|
|
|
services = {
|
2019-07-19 22:10:16 +00:00
|
|
|
nginx.virtualHosts = {
|
|
|
|
"prometheus.shack" = {
|
|
|
|
locations."/".proxyPass = "http://localhost:9090";
|
|
|
|
};
|
|
|
|
"alert.prometheus.shack" = {
|
|
|
|
locations."/".proxyPass = "http://localhost:9093";
|
|
|
|
};
|
|
|
|
};
|
2019-06-20 20:21:56 +00:00
|
|
|
prometheus = {
|
|
|
|
enable = true;
|
|
|
|
scrapeConfigs = [
|
|
|
|
{
|
|
|
|
job_name = "node";
|
|
|
|
scrape_interval = "10s";
|
|
|
|
static_configs = [
|
|
|
|
{
|
|
|
|
targets = [
|
2020-07-22 14:25:00 +00:00
|
|
|
"wolf.shack:9100"
|
2019-06-20 20:21:56 +00:00
|
|
|
];
|
|
|
|
labels = {
|
|
|
|
alias = "wolf.shack";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
targets = [
|
2020-07-22 14:25:00 +00:00
|
|
|
"infra01.shack:9100"
|
|
|
|
];
|
|
|
|
labels = {
|
|
|
|
alias = "infra01.shack";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
targets = [
|
|
|
|
"unifi.shack:9130"
|
2019-06-20 20:21:56 +00:00
|
|
|
];
|
|
|
|
labels = {
|
|
|
|
alias = "unifi.shack";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
targets = [
|
2020-07-22 14:25:00 +00:00
|
|
|
"puyak.shack:9100" # puyak.shack
|
2019-06-20 20:21:56 +00:00
|
|
|
];
|
|
|
|
labels = {
|
|
|
|
alias = "puyak.shack";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
targets = [
|
|
|
|
"phenylbutazon.shack:9100"
|
|
|
|
];
|
|
|
|
labels = {
|
|
|
|
alias = "phenylbutazon.shack";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
{
|
|
|
|
targets = [
|
|
|
|
"ibuprofen.shack:9100"
|
|
|
|
];
|
|
|
|
labels = {
|
|
|
|
alias = "ibuprofen.shack";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
2020-07-22 14:25:00 +00:00
|
|
|
{
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
2019-06-20 20:21:56 +00:00
|
|
|
];
|
2019-10-15 12:08:00 +00:00
|
|
|
alertmanagers = [
|
|
|
|
{ scheme = "http";
|
|
|
|
path_prefix = "/";
|
|
|
|
static_configs = [ { targets = [ "localhost:9093" ]; } ];
|
|
|
|
}
|
|
|
|
];
|
2019-06-20 20:21:56 +00:00
|
|
|
alertmanager = {
|
|
|
|
enable = true;
|
2020-09-13 21:52:22 +00:00
|
|
|
listenAddress = "127.0.0.1";
|
2020-09-13 22:26:21 +00:00
|
|
|
webExternalUrl = "http://alert.prometheus.shack";
|
|
|
|
logLevel = "debug";
|
|
|
|
|
2019-06-20 20:21:56 +00:00
|
|
|
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";
|
2020-09-13 21:52:22 +00:00
|
|
|
"email_configs" = [ ];
|
2019-06-20 20:21:56 +00:00
|
|
|
"webhook_configs" = [
|
|
|
|
{
|
2020-09-13 22:26:21 +00:00
|
|
|
"url" = "http://localhost:16320";
|
2019-06-20 20:21:56 +00:00
|
|
|
"send_resolved" = true;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|