diff options
author | tv <tv@krebsco.de> | 2019-11-29 16:37:14 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2019-11-29 16:37:14 +0100 |
commit | 7920ebebf0ad119ee07e3ef58c832c9304903d27 (patch) | |
tree | c934271f6c6786a8e34c28c0368c9b06ab72a071 /krebs/2configs/shack/prometheus/alert-rules.nix | |
parent | 7dff5292e959ac977939273101c84dd39f3cb86d (diff) | |
parent | 5f1a526486b647407d71bdec16e3713d0da8367e (diff) |
Merge remote-tracking branch 'prism/master'
Diffstat (limited to 'krebs/2configs/shack/prometheus/alert-rules.nix')
-rw-r--r-- | krebs/2configs/shack/prometheus/alert-rules.nix | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/krebs/2configs/shack/prometheus/alert-rules.nix b/krebs/2configs/shack/prometheus/alert-rules.nix new file mode 100644 index 000000000..096c551ba --- /dev/null +++ b/krebs/2configs/shack/prometheus/alert-rules.nix @@ -0,0 +1,102 @@ +{ lib }: +with lib; + +let + deviceFilter = ''device!="ramfs",device!="rpc_pipefs",device!="lxcfs",device!="nsfs",device!="borgfs"''; +in mapAttrsToList (name: opts: { + alert = name; + expr = opts.condition; + for = opts.time or "2m"; + labels = if (opts.page or true) then { severity = "page"; } else {}; + annotations = { + summary = opts.summary; + description = opts.description; + }; +}) { + node_down = { + condition = ''up{job="node"} == 0''; + summary = "{{$labels.alias}}: Node is down."; + description = "{{$labels.alias}} has been down for more than 2 minutes."; + }; + node_systemd_service_failed = { + condition = ''node_systemd_unit_state{state="failed"} == 1''; + summary = "{{$labels.alias}}: Service {{$labels.name}} failed to start."; + description = "{{$labels.alias}} failed to (re)start service {{$labels.name}}."; + }; + node_filesystem_full_80percent = { + condition = ''sort(node_filesystem_free_bytes{${deviceFilter}} < node_filesystem_size_bytes{${deviceFilter}} * 0.2) / 1024^3''; + time = "10m"; + summary = "{{$labels.alias}}: Filesystem is running out of space soon."; + description = "{{$labels.alias}} device {{$labels.device}} on {{$labels.mountpoint}} got less than 20% space left on its filesystem."; + }; + node_filesystem_full_in_7d = { + condition = ''predict_linear(node_filesystem_free_bytes{${deviceFilter}}[2d], 7*24*3600) <= 0''; + time = "1h"; + summary = "{{$labels.alias}}: Filesystem is running out of space in 7 days."; + description = "{{$labels.alias}} device {{$labels.device}} on {{$labels.mountpoint}} is running out of space of in approx. 7 days"; + }; + node_filesystem_full_in_30d = { + condition = ''predict_linear(node_filesystem_free_bytes{${deviceFilter}}[30d], 30*24*3600) <= 0''; + time = "1h"; + summary = "{{$labels.alias}}: Filesystem is running out of space in 30 days."; + description = "{{$labels.alias}} device {{$labels.device}} on {{$labels.mountpoint}} is running out of space of in approx. 30 days"; + }; + node_filedescriptors_full_in_3h = { + condition = ''predict_linear(node_filefd_allocated[3h], 3*3600) >= node_filefd_maximum''; + time = "20m"; + 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"; + }; + node_filedescriptors_full_in_7d = { + condition = ''predict_linear(node_filefd_allocated[7d], 7*24*3600) >= node_filefd_maximum''; + time = "1h"; + summary = "{{$labels.alias}} is running out of available file descriptors in 7 days."; + description = "{{$labels.alias}} is running out of available file descriptors in approx. 7 days"; + }; + node_load15 = { + condition = ''node_load15 / on(alias) count(node_cpu_seconds_total{mode="system"}) by (alias) >= 1.0''; + time = "10m"; + summary = "{{$labels.alias}}: Running on high load: {{$value}}"; + description = "{{$labels.alias}} is running with load15 > 1 for at least 5 minutes: {{$value}}"; + }; + node_ram_using_90percent = { + condition = "node_memory_MemFree_bytes + node_memory_Buffers_bytes + node_memory_Cached_bytes < node_memory_MemTotal_bytes * 0.1"; + time = "1h"; + summary = "{{$labels.alias}}: Using lots of RAM."; + description = "{{$labels.alias}} is using at least 90% of its RAM for at least 1 hour."; + }; + node_swap_using_30percent = { + condition = "node_memory_SwapTotal_bytes - (node_memory_SwapFree_bytes + node_memory_SwapCached_bytes) > node_memory_SwapTotal_bytes * 0.3"; + time = "30m"; + summary = "{{$labels.alias}}: Using more than 30% of its swap."; + description = "{{$labels.alias}} is using 30% of its swap space for at least 30 minutes."; + }; + node_visible_confluence_space = { + condition = "node_visible_confluence_space != 0"; + summary = "crowd prometheus cann see the {{$labels.space_name}} confluence space!"; + description = "crowd user `prometheus` can see the `{{$labels.space_name}}` confluence space."; + }; + node_hwmon_temp = { + condition = "node_hwmon_temp_celsius > node_hwmon_temp_crit_celsius*0.9 OR node_hwmon_temp_celsius > node_hwmon_temp_max_celsius*0.95"; + time = "5m"; + summary = "{{$labels.alias}}: Sensor {{$labels.sensor}}/{{$labels.chip}} temp is high: {{$value}} "; + description = "{{$labels.alias}} reports hwmon sensor {{$labels.sensor}}/{{$labels.chip}} temperature value is nearly critical: {{$value}}"; + }; + node_conntrack_limit = { + condition = "node_nf_conntrack_entries_limit - node_nf_conntrack_entries < 1000"; + time = "5m"; + summary = "{{$labels.alias}}: Number of tracked connections high"; + description = "{{$labels.alias}} has only {{$value}} free slots for connection tracking available."; + }; + node_reboot = { + condition = "time() - node_boot_time_seconds < 300"; + summary = "{{$labels.alias}}: Reboot"; + description = "{{$labels.alias}} just rebooted."; + }; + node_uptime = { + condition = "time() - node_boot_time_seconds > 2592000"; + page = false; + summary = "{{$labels.alias}}: Uptime monster"; + description = "{{$labels.alias}} has been up for more than 30 days."; + }; +} |