mio-ops/profiles/prometheus.nix

215 lines
7.6 KiB
Nix
Raw Normal View History

2020-05-26 12:13:24 +00:00
# NixOps configuration for the hosts running Prometheus on a Cardano node
{ config, pkgs, lib, ... }:
{
services = {
prometheus = {
enable = true;
2020-05-27 11:56:19 +00:00
webExternalUrl = "https://monitoring.mcwhirter.io/prometheus/";
2021-11-16 04:57:23 +00:00
extraFlags = [ "--storage.tsdb.retention.time 8760h" ];
2020-05-27 11:56:19 +00:00
exporters = {
node = {
enable = true;
openFirewall = true;
enabledCollectors = [
"systemd"
"tcpstat"
"conntrack"
"diskstats"
"entropy"
"filefd"
"filesystem"
"loadavg"
"meminfo"
"netdev"
"netstat"
"stat"
"time"
"ntp"
"timex"
"vmstat"
"logind"
"interrupts"
"ksmd"
"processes"
];
};
};
#alertmanager = {
# enable = true;
# webExternalUrl = "https://monitoring.mcwhirter.io/alertmanager/";
# configuration = [
# ];
#};
#alertmanagers = [ {
# scheme = "http";
# path_prefix = "/";
# static_configs = [ {
# targets = [ "airgead.mcwhirter.io:9093" ];
# } ];
#} ];
2021-11-16 04:57:23 +00:00
rules = [
(builtins.toJSON {
groups = [{
2020-05-26 12:13:24 +00:00
name = "system";
rules = [
{
alert = "node_down";
expr = "up == 0";
for = "5m";
2021-11-16 04:57:23 +00:00
labels = { severity = "page"; };
2020-05-26 12:13:24 +00:00
annotations = {
summary = "{{$labels.alias}}: Node is down.";
2021-11-16 04:57:23 +00:00
description =
"{{$labels.alias}} has been down for more than 5 minutes.";
2020-05-26 12:13:24 +00:00
};
}
{
alert = "node_systemd_service_failed";
2021-11-16 04:57:23 +00:00
expr = ''node_systemd_unit_state{state="failed"} == 1'';
2020-05-26 12:13:24 +00:00
for = "4m";
2021-11-16 04:57:23 +00:00
labels = { severity = "page"; };
2020-05-26 12:13:24 +00:00
annotations = {
2021-11-16 04:57:23 +00:00
summary =
"{{$labels.alias}}: Service {{$labels.name}} failed to start.";
description =
"{{$labels.alias}} failed to (re)start service {{$labels.name}}.";
2020-05-26 12:13:24 +00:00
};
}
{
alert = "node_filesystem_full_90percent";
2021-11-16 04:57:23 +00:00
expr = ''
sort(node_filesystem_free_bytes{device!="ramfs"} < node_filesystem_size_bytes{device!="ramfs"} * 0.1) / 1024^3'';
2020-05-26 12:13:24 +00:00
for = "5m";
2021-11-16 04:57:23 +00:00
labels = { severity = "page"; };
2020-05-26 12:13:24 +00:00
annotations = {
2021-11-16 04:57:23 +00:00
summary =
"{{$labels.alias}}: Filesystem is running out of space soon.";
description =
"{{$labels.alias}} device {{$labels.device}} on {{$labels.mountpoint}} got less than 10% space left on its filesystem.";
2020-05-26 12:13:24 +00:00
};
}
{
alert = "node_filesystem_full_in_4h";
2021-11-16 04:57:23 +00:00
expr = ''
predict_linear(node_filesystem_free_bytes{device!="ramfs",device!="tmpfs",fstype!="autofs",fstype!="cd9660"}[4h], 4*3600) <= 0'';
2020-05-26 12:13:24 +00:00
for = "5m";
2021-11-16 04:57:23 +00:00
labels = { severity = "page"; };
2020-05-26 12:13:24 +00:00
annotations = {
2021-11-16 04:57:23 +00:00
summary =
"{{$labels.alias}}: Filesystem is running out of space in 4 hours.";
description =
"{{$labels.alias}} device {{$labels.device}} on {{$labels.mountpoint}} is running out of space of in approx. 4 hours";
2020-05-26 12:13:24 +00:00
};
}
{
alert = "node_filedescriptors_full_in_3h";
2021-11-16 04:57:23 +00:00
expr =
"predict_linear(node_filefd_allocated[1h], 3*3600) >= node_filefd_maximum";
2020-05-26 12:13:24 +00:00
for = "20m";
2021-11-16 04:57:23 +00:00
labels = { severity = "page"; };
2020-05-26 12:13:24 +00:00
annotations = {
2021-11-16 04:57:23 +00:00
summary =
"{{$labels.alias}} is running out of available file descriptors in 3 hours.";
description =
"{{$labels.alias}} is running out of available file descriptors in approx. 3 hours";
2020-05-26 12:13:24 +00:00
};
}
{
alert = "node_load1_90percent";
2021-11-16 04:57:23 +00:00
expr = ''
node_load1 / on(alias) count(node_cpu_seconds_total{mode="system"}) by (alias) >= 0.9'';
2020-05-26 12:13:24 +00:00
for = "1h";
2021-11-16 04:57:23 +00:00
labels = { severity = "page"; };
2020-05-26 12:13:24 +00:00
annotations = {
summary = "{{$labels.alias}}: Running on high load.";
2021-11-16 04:57:23 +00:00
description =
"{{$labels.alias}} is running with > 90% total load for at least 1h.";
2020-05-26 12:13:24 +00:00
};
}
{
alert = "node_cpu_util_90percent";
2021-11-16 04:57:23 +00:00
expr = ''
100 - (avg by (alias) (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) >= 90'';
2020-05-26 12:13:24 +00:00
for = "1h";
2021-11-16 04:57:23 +00:00
labels = { severity = "page"; };
2020-05-26 12:13:24 +00:00
annotations = {
summary = "{{$labels.alias}}: High CPU utilization.";
2021-11-16 04:57:23 +00:00
description =
"{{$labels.alias}} has total CPU utilization over 90% for at least 1h.";
2020-05-26 12:13:24 +00:00
};
}
{
alert = "node_ram_using_99percent";
2021-11-16 04:57:23 +00:00
expr =
"node_memory_MemFree_bytes + node_memory_Buffers_bytes + node_memory_Cached_bytes < node_memory_MemTotal_bytes * 0.01";
2020-05-26 12:13:24 +00:00
for = "30m";
2021-11-16 04:57:23 +00:00
labels = { severity = "page"; };
2020-05-26 12:13:24 +00:00
annotations = {
summary = "{{$labels.alias}}: Using lots of RAM.";
2021-11-16 04:57:23 +00:00
description =
"{{$labels.alias}} is using at least 90% of its RAM for at least 30 minutes now.";
2020-05-26 12:13:24 +00:00
};
}
{
alert = "node_swap_using_80percent";
2021-11-16 04:57:23 +00:00
expr =
"node_memory_SwapTotal_bytes - (node_memory_SwapFree_bytes + node_memory_SwapCached_bytes) > node_memory_SwapTotal_bytes * 0.8";
2020-05-26 12:13:24 +00:00
for = "10m";
2021-11-16 04:57:23 +00:00
labels = { severity = "page"; };
2020-05-26 12:13:24 +00:00
annotations = {
summary = "{{$labels.alias}}: Running out of swap soon.";
2021-11-16 04:57:23 +00:00
description =
"{{$labels.alias}} is using 80% of its swap space for at least 10 minutes now.";
2020-05-26 12:13:24 +00:00
};
}
{
alert = "node_time_unsync";
2021-11-16 04:57:23 +00:00
expr =
"abs(node_timex_offset_seconds) > 0.050 or node_timex_sync_status != 1";
2020-05-26 12:13:24 +00:00
for = "1m";
2021-11-16 04:57:23 +00:00
labels = { severity = "page"; };
2020-05-26 12:13:24 +00:00
annotations = {
summary = "{{$labels.alias}}: Clock out of sync with NTP";
2021-11-16 04:57:23 +00:00
description =
"{{$labels.alias}} Local clock offset is too large or out of sync with NTP";
2020-05-26 12:13:24 +00:00
};
}
];
2021-11-16 04:57:23 +00:00
}];
})
];
2020-05-26 12:13:24 +00:00
scrapeConfigs = [
{
job_name = "prometheus";
scrape_interval = "5s";
2021-11-16 04:57:23 +00:00
static_configs = [{
targets = [ "localhost:9090" ];
labels = { alias = "prometheus"; };
}];
2020-05-26 12:13:24 +00:00
}
{
job_name = "cardano-node";
scrape_interval = "10s";
2021-11-16 04:57:23 +00:00
static_configs = [{
targets = [ "127.0.0.1:12798" ];
labels = { alias = "airgead"; };
}];
2020-05-26 12:13:24 +00:00
}
{
job_name = "node";
scrape_interval = "10s";
2021-11-16 04:57:23 +00:00
static_configs = [{
targets = [ "airgead.mcwhirter.io:9100" ];
labels = { alias = "airgead.mcwhirter.io"; };
}];
2020-05-26 12:13:24 +00:00
}
];
};
};
}