add alerting

This commit is contained in:
Your Name
2025-03-17 16:06:35 +00:00
parent d0ca70c546
commit 581f35cad3
6 changed files with 146 additions and 9 deletions
+14 -4
View File
@@ -40,14 +40,23 @@ groups:
description: "Container {{ $labels.name }} CPU usage is > 80% for 5 minutes"
- alert: ContainerHighMemory
expr: (container_memory_usage_bytes{name!=""} / container_spec_memory_limit_bytes{name!=""} * 100) > 80
for: 5m
# First filter out containers with memory limits, then calculate percentage
expr: |
(
container_memory_usage_bytes{name!=""}
/
container_spec_memory_limit_bytes{name!=""}
* 100 > 90
)
and
container_spec_memory_limit_bytes{name!=""} > 0
for: 10m
labels:
severity: warning
annotations:
summary: "High memory usage in container {{ $labels.name }}"
description: "Container {{ $labels.name }} memory usage is > 80% for 5 minutes"
description: "Container {{ $labels.name }} ({{ $labels.image }}) memory usage is {{ printf \"%.1f\" $value }}% of its limit for 10 minutes"
- alert: ContainerDown
expr: absent(container_last_seen{name!=""})
for: 1m
@@ -65,3 +74,4 @@ groups:
annotations:
summary: "Container {{ $labels.name }} restarting frequently"
description: "Container {{ $labels.name }} has restarted more than 2 times in the last 15 minutes"