Your disk alert fires and clears every few minutes around 80%, spamming Slack. How do you fix the alerting?
AdvancedScenarioScenarios: health checks, monitoring and alerts
Answer
Situation read → The value oscillates around a single threshold and every check sends a message: no deduplication, no hysteresis.
What I'd do →
- Deduplicate: store a state file per alert key (
alerts/disk-var) with the time it fired; suppress repeats within a cooldown (for example, 1 hour). - Hysteresis: fire at 85%, clear only below 80%.
firing=$([[ -e $state ]] && echo 1 || echo 0) if (( pct >= 85 )) || (( firing && pct >= 80 )); then alert; elif (( firing )); then resolve; fi - Duration: require N consecutive bad checks before alerting (keep a counter in the state file).
- Send resolved messages so people know when to stop looking.
- Separate warning (ticket or channel) from critical (page).
Why → Alert fatigue makes people mute channels, and then the real alert is missed.
Interview tip → Use the word "hysteresis". It is what Prometheus for: clauses and Alertmanager grouping solve in larger setups.
More on Scenarios: health checks, monitoring and alerts
You are asked for a host health-check script covering disk, memory, systemd services and an HTTP endpoint. How do you design it?IntermediateA server reports `No space left on device` but `df -h` shows 40% free. What would you add to the health checks?BeginnerAlert when any certificate under `/etc/letsencrypt/live` expires within 21 days.IntermediateA developer wrote a Bash loop that restarts the app whenever its process disappears. What do you suggest instead?IntermediateYou suspect a memory leak in a service. How do you collect evidence with a script before involving developers?AdvancedHow do you know a scheduled job actually ran, not just that it did not report failure?Intermediate