stockholm/krebs/2configs/shack/prometheus/server.nix

151 lines
3.7 KiB
Nix
Raw Normal View History

2019-06-20 20:21:56 +00:00
{ pkgs, lib, config, ... }:
# from https://gist.github.com/globin/02496fd10a96a36f092a8e7ea0e6c7dd
{
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 = [
"wolf.shack:9100"
2019-06-20 20:21:56 +00:00
];
labels = {
alias = "wolf.shack";
};
}
{
targets = [
"infra01.shack:9100"
];
labels = {
alias = "infra01.shack";
};
}
{
targets = [
"unifi.shack:9130"
2019-06-20 20:21:56 +00:00
];
labels = {
alias = "unifi.shack";
};
}
{
targets = [
"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";
};
}
];
}
{
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
];
alertmanagers = [
{ scheme = "http";
path_prefix = "/";
static_configs = [ { targets = [ "localhost:9093" ]; } ];
}
];
2019-06-20 20:21:56 +00:00
alertmanager = {
enable = true;
listenAddress = "127.0.0.1";
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";
"email_configs" = [ ];
2019-06-20 20:21:56 +00:00
"webhook_configs" = [
{
"url" = "http://localhost:16320";
2019-06-20 20:21:56 +00:00
"send_resolved" = true;
}
];
}
];
};
};
};
};
}