This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

1# vmalert rules. metrics runs against VictoriaMetrics, logs (LogsQL) against 2# VictoriaLogs; vmalert needs one instance per datasource type. 3{ lib }: 4let 5 inherit (import ./default.nix) alwaysOn; 6 7 alert = name: expr: for: summary: { 8 alert = name; 9 inherit expr for; 10 labels.severity = "warning"; 11 annotations.summary = summary; 12 }; 13in 14{ 15 metrics.groups = [ 16 { 17 name = "hosts"; 18 rules = [ 19 # absent_over_time keeps the host label of its selector, so one term 20 # per machine yields one alert per missing machine. 21 (alert "HostDown" (lib.concatMapStringsSep " or " ( 22 host: ''absent_over_time(host_uptime{host="${host}"}[10m])'' 23 ) alwaysOn) "0m" "{{ $labels.host }} sent no metrics for 10 minutes") 24 # Network mounts (and their autofs placeholders) are reported by 25 # every machine that mounts them; the agent drops tmpfs & co. 26 # neoprism's /var/download is always above 90%, see DownloadSpace*. 27 (alert "DiskAlmostFull" 28 ''host_filesystem_used_ratio{filesystem!~"cifs|smb3|nfs|nfs4|autofs|fuse.sshfs"} > 0.9 unless on (host, mountpoint) host_filesystem_used_ratio{host="neoprism",mountpoint="/var/download"}'' 29 "15m" 30 "{{ $labels.host }}: {{ $labels.mountpoint }} is {{ $value | humanizePercentage }} full" 31 ) 32 (alert "DownloadSpaceLow" 33 ''host_filesystem_free_bytes{host="neoprism",mountpoint="/var/download"} < 200e9'' 34 "15m" 35 "{{ $labels.host }}: {{ $labels.mountpoint }} has only {{ $value | humanize }}B free" 36 ) 37 ( 38 alert "DownloadSpaceCritical" 39 ''host_filesystem_free_bytes{host="neoprism",mountpoint="/var/download"} < 100e9'' 40 "15m" 41 "{{ $labels.host }}: {{ $labels.mountpoint }} has only {{ $value | humanize }}B free" 42 // { 43 labels.severity = "critical"; 44 } 45 ) 46 (alert "HighMemory" "1 - host_memory_available_bytes / host_memory_total_bytes > 0.95" "15m" 47 "{{ $labels.host }} uses {{ $value | humanizePercentage }} of its memory" 48 ) 49 (alert "MemoryPressure" "rate(host_pressure_memory_some_seconds_total[10m]) > 0.1" "5m" 50 "{{ $labels.host }}: tasks stalled on memory {{ $value | humanizePercentage }} of the time" 51 ) 52 (alert "OOMKill" "increase(host_memory_oom_kill_events_total[10m]) > 0" "0m" 53 "{{ $labels.host }}: {{ $value }} processes OOM-killed in the last 10 minutes" 54 ) 55 # NVMe drives set critical_warning bit 0x04 (and so fail smart_status) 56 # once they exceed their rated endurance; their wear is covered by 57 # NvmeSpareLow instead. 251 masks out bit 0x04. 58 (alert "SmartFailed" 59 ''smartctl_device_smart_status == 0 unless on (host, device) smartctl_device{protocol="NVMe"}'' 60 "5m" 61 "{{ $labels.host }}: {{ $labels.device }} fails its SMART health check" 62 ) 63 (alert "NvmeCriticalWarning" "bitmap_and(smartctl_device_critical_warning, 251) != 0" "5m" 64 "{{ $labels.host }}: {{ $labels.device }} reports critical warning {{ $value }}" 65 ) 66 (alert "NvmeMediaErrors" "increase(smartctl_device_media_errors[1h]) > 0" "0m" 67 "{{ $labels.host }}: {{ $labels.device }} had {{ $value }} new media errors in the last hour" 68 ) 69 (alert "NvmeSpareLow" "smartctl_device_available_spare < smartctl_device_available_spare_threshold" 70 "5m" 71 "{{ $labels.host }}: {{ $labels.device }} has only {{ $value }}% spare left" 72 ) 73 ]; 74 } 75 { 76 name = "gatus"; 77 rules = [ 78 (alert "GatusEndpointDown" "gatus_results_endpoint_success == 0" "5m" 79 "{{ $labels.name }} fails as seen from {{ $labels.vantage }}" 80 ) 81 ]; 82 } 83 ]; 84 85 logs.groups = [ 86 { 87 name = "journal"; 88 type = "vlogs"; 89 interval = "1m"; 90 rules = [ 91 (alert "SystemdUnitFailed" 92 ''_time:15m "Failed with result" | stats by (host, unit) count() as failures'' 93 "0m" 94 "{{ $labels.unit }} failed on {{ $labels.host }}" 95 ) 96 ]; 97 } 98 ]; 99}