host.yml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. # Host + container resource alerts (node-exporter + cAdvisor).
  2. # Routed via alertmanager → discord bridge: severity=critical|warning →
  3. # #briven-alerts, info → #briven-deploys. Severity labels MUST match the
  4. # route matchers in infra/observability/alertmanager/alertmanager.yml.
  5. #
  6. # Thresholds tuned for kvm4: 4 vCPU, 16 GB RAM, 4 GB swap, on an
  7. # oversubscribed Hostinger VPS (CPU steal is a real signal here).
  8. #
  9. # NOTE: Dokploy builds can run as a HOST process (no container cgroup), so
  10. # a runaway build is caught by the host memory/swap alerts below, not by
  11. # the per-container cAdvisor alert. Both layers are intentional.
  12. groups:
  13. - name: briven-host
  14. interval: 30s
  15. rules:
  16. - alert: HostMemoryCritical
  17. expr: |
  18. node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 5
  19. for: 5m
  20. labels:
  21. severity: critical
  22. annotations:
  23. summary: 'host {{ $labels.instance }} memory critically low'
  24. description: 'Available memory <5% for 5m ({{ $value | printf "%.1f" }}%). Builds/exec will start failing with OCI "unable to start container process".'
  25. - alert: HostMemoryHigh
  26. expr: |
  27. node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes * 100 < 10
  28. for: 10m
  29. labels:
  30. severity: warning
  31. annotations:
  32. summary: 'host {{ $labels.instance }} memory low'
  33. description: 'Available memory <10% for 10m ({{ $value | printf "%.1f" }}%).'
  34. - alert: HostSwapHigh
  35. expr: |
  36. (1 - node_memory_SwapFree_bytes / node_memory_SwapTotal_bytes) * 100 > 50
  37. for: 10m
  38. labels:
  39. severity: warning
  40. annotations:
  41. summary: 'host {{ $labels.instance }} swapping heavily'
  42. description: 'Swap usage >50% for 10m ({{ $value | printf "%.0f" }}%). Sustained swap means a process (often a build) is exhausting RAM.'
  43. - alert: HostDiskHigh
  44. # rootfs only. With --path.rootfs=/host, node-exporter reports the
  45. # host root as mountpoint "/". If your build reports "/host", widen
  46. # the matcher to mountpoint=~"/|/host".
  47. expr: |
  48. (1 - node_filesystem_avail_bytes{mountpoint="/",fstype!~"tmpfs|overlay|squashfs"}
  49. / node_filesystem_size_bytes{mountpoint="/",fstype!~"tmpfs|overlay|squashfs"}) * 100 > 85
  50. for: 10m
  51. labels:
  52. severity: warning
  53. annotations:
  54. summary: 'host {{ $labels.instance }} disk >85%'
  55. description: 'Root filesystem {{ $value | printf "%.0f" }}% full. Run docker builder/image prune.'
  56. - alert: HostDiskCritical
  57. expr: |
  58. (1 - node_filesystem_avail_bytes{mountpoint="/",fstype!~"tmpfs|overlay|squashfs"}
  59. / node_filesystem_size_bytes{mountpoint="/",fstype!~"tmpfs|overlay|squashfs"}) * 100 > 92
  60. for: 5m
  61. labels:
  62. severity: critical
  63. annotations:
  64. summary: 'host {{ $labels.instance }} disk >92%'
  65. description: 'Root filesystem {{ $value | printf "%.0f" }}% full — deploys and Docker will fail imminently.'
  66. - alert: HostLoadHigh
  67. # 5-min load above 2x core count. count(idle cpu series) = vCPU count.
  68. expr: |
  69. node_load5 > 2 * count by (instance) (node_cpu_seconds_total{mode="idle"})
  70. for: 10m
  71. labels:
  72. severity: warning
  73. annotations:
  74. summary: 'host {{ $labels.instance }} load high'
  75. description: '5-min load {{ $value | printf "%.1f" }} is >2x vCPU count for 10m.'
  76. - alert: HostCPUStealHigh
  77. # Hostinger oversubscription signal — the hypervisor is taking CPU.
  78. expr: |
  79. avg by (instance) (rate(node_cpu_seconds_total{mode="steal"}[5m])) * 100 > 25
  80. for: 15m
  81. labels:
  82. severity: warning
  83. annotations:
  84. summary: 'host {{ $labels.instance }} CPU steal >25%'
  85. description: 'Hypervisor stealing {{ $value | printf "%.0f" }}% CPU for 15m. VPS is oversold — consider resizing or moving load.'
  86. - alert: ContainerMemoryHigh
  87. # Any single container >6 GB RSS. Catches containerized heavy builds
  88. # and memory-leaking apps. Host-level builds are caught by HostMemory*.
  89. expr: |
  90. container_memory_rss{name!=""} > 6e9
  91. for: 10m
  92. labels:
  93. severity: warning
  94. annotations:
  95. summary: 'container {{ $labels.name }} using >6 GB RAM'
  96. description: '{{ $labels.name }} RSS {{ $value | humanize1024 }}B for 10m on a 16 GB host.'
  97. - alert: ContainerOOMKilled
  98. expr: |
  99. increase(container_oom_events_total{name!=""}[10m]) > 0
  100. labels:
  101. severity: warning
  102. annotations:
  103. summary: 'container {{ $labels.name }} OOM-killed'
  104. description: '{{ $labels.name }} hit an OOM event in the last 10m.'
  105. - alert: ContainerRestarting
  106. expr: |
  107. changes(container_start_time_seconds{name!=""}[15m]) > 2
  108. labels:
  109. severity: warning
  110. annotations:
  111. summary: 'container {{ $labels.name }} restart-looping'
  112. description: '{{ $labels.name }} restarted >2 times in 15m.'