From e61e02fb391116e102f8d68c7361bd0a78c9480d Mon Sep 17 00:00:00 2001 From: Samir Boulahtit Date: Sun, 1 Mar 2026 17:57:38 +0100 Subject: [PATCH] fix(redis): configure maxmemory and eviction policy to prevent OOM Redis had no maxmemory set, causing the Prometheus alert expression (used/max) to evaluate to +Inf. Set maxmemory to 100mb with allkeys-lru eviction policy, and guard the alert expression against division by zero. Co-Authored-By: Claude Opus 4.6 --- docker-compose.yml | 1 + monitoring/prometheus/alert.rules.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 526450e4..c2059abf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,7 @@ services: redis: image: redis:7-alpine restart: always + command: redis-server --maxmemory 100mb --maxmemory-policy allkeys-lru ports: - "6380:6379" # Use 6380 to avoid conflict with host Redis mem_limit: 128m diff --git a/monitoring/prometheus/alert.rules.yml b/monitoring/prometheus/alert.rules.yml index 7a87ac6c..eeddb658 100644 --- a/monitoring/prometheus/alert.rules.yml +++ b/monitoring/prometheus/alert.rules.yml @@ -140,7 +140,7 @@ groups: description: "Redis exporter cannot connect to Redis for 1 minute. Background tasks (emails, Celery) are not processing." - alert: RedisHighMemoryUsage - expr: redis_memory_used_bytes / redis_memory_max_bytes * 100 > 80 + expr: redis_memory_max_bytes > 0 and redis_memory_used_bytes / redis_memory_max_bytes * 100 > 80 for: 5m labels: severity: warning