Alerting, Health-Check Automation and Operational Runbooks
What Good Operations Looks Like
- Problems are found by alerts, not by users
- Every alert has a runbook with first steps
- Routine checks are automated and recorded
- Incidents lead to written reviews and fixes
- Changes are planned, tested and reversible
Daily, Weekly and Monthly Routine
| Frequency | Task |
|---|---|
| Daily | HDFS capacity and growth, missing/under-replicated blocks, dead DataNodes, unhealthy NodeManagers, failed jobs and top resource users, backup job results, alert review |
| Weekly | Small file and quota report, top users, long-running jobs, log disk usage, pending OS patches, certificate expiry list |
| Monthly | Capacity forecast, access review (Ranger and groups), restore test, disaster recovery check, configuration drift check, upgrade planning |
| Quarterly | Failover tests (NameNode, RM, ZooKeeper), security review, game day |
Daily Health Report Script
bash
#!/bin/bash
# daily_report.sh : sends one email summary every morning (cron: 0 7 * * *)
{
echo "== HDFS =="
hdfs dfsadmin -report | sed -n '1,12p'
hdfs dfsadmin -report -dead | head -20
hdfs fsck / 2>/dev/null | tail -15
echo; echo "== HA =="
hdfs haadmin -getAllServiceState; yarn rmadmin -getAllServiceState
echo; echo "== YARN =="
yarn node -list -states UNHEALTHY,LOST
yarn application -list -appStates FAILED 2>/dev/null | head -20
echo; echo "== Backups =="
tail -3 /var/log/hadoop-backup/last_run.log
echo; echo "== Disk (workers sample) =="
ansible workers -m shell -a "df -h /data/* | awk '\$5+0>80'" -o 2>/dev/null | head -20
} | mail -s "Hadoop daily report $(date +%F)" hadoop-admins@example.com
Alert Severity Levels
| Level | Meaning | Example | Response |
|---|---|---|---|
| P1 Critical | Outage or data at risk | No active NameNode, missing blocks, DR down | Page on-call immediately, 15 min |
| P2 High | Degraded service | One DataNode rack down, queue backlog | Respond within 1 hour |
| P3 Warning | Will become a problem | Disk 80% full, cert expires in 30 days | Next business day |
| P4 Info | Awareness | Job failure rate slightly up | Weekly review |
Runbook Template
text
RUNBOOK: <Alert name>
Impact: who/what is affected
Severity: P1/P2/P3
Detect: which alert, dashboard, command
Diagnose: step-by-step commands with expected output
Fix: numbered steps; mark any risky step
Verify: commands proving it is fixed
Escalate: who to call, when (time limit)
After: follow-ups, ticket, review needed?
Owner / last tested date
Example Runbook: DataNode Disk Full
text
Impact: Writes to that node fail or are redirected, job slowness, balancer imbalance
Detect: Alert DiskAlmostFull{mountpoint=/data/d3}
Diagnose:
1. df -h /data/* -> which volume
2. du -sh /data/d3/dn/current/* | sort -h | tail
3. hdfs dfsadmin -report -datanode worker12 -> DFS Used%, Non DFS Used (logs? tmp?)
Fix:
a. If non-DFS data (logs, core dumps, tmp): remove/rotate it (safe)
b. If HDFS data: run balancer -> hdfs balancer -threshold 5
c. If whole cluster is >80%: escalate P2 to capacity planning, add nodes or delete old data
d. Do NOT delete files inside /data/d3/dn/current by hand
Verify: usage under 80%, no new alerts
Escalate: if the cluster is above 85% used and growing, page the platform lead
Example Runbook: HDFS in Safe Mode
text
Detect: NameNode UI banner "Safe mode is ON", clients get SafeModeException
Diagnose:
1. hdfs dfsadmin -safemode get
2. NameNode log: "reported blocks X needs additional Y blocks"
3. hdfs dfsadmin -report | head -- how many DataNodes are live?
Fix:
a. Startup still in progress and DataNodes are registering -> wait
b. DataNodes down -> start them (systemctl), check network/firewall
c. Real missing blocks (disks lost) -> restore nodes first; only then consider
`hdfs dfsadmin -safemode leave` with approval and a list of lost files from fsck
Verify: safemode OFF, MissingBlocks = 0
Example Runbook: Dead DataNode
- Is the host reachable?
ping,ssh - Is the process running?
systemctl status hadoop-datanode,jps - Read the last 100 lines of the DataNode log
- Common causes: out of memory, disk failure,
Too many open files, clusterID mismatch - Restart once. If it fails again, do not keep restarting in a loop, investigate
- If the node will be out for more than 1 hour, check under-replicated blocks and re-replication rate
Change Management
- Every config change in Git with a pull request and review
- Test on a lab or one canary node first
- Rolling changes with health checks between batches
- A written rollback step in the change ticket
- Announce maintenance windows to users
Learn from Incidents: Blameless Review
| Question | Example answer |
|---|---|
| What happened (timeline)? | 10:02 alert, 10:10 on-call acknowledged, 10:40 fixed |
| Why (root cause, not person)? | No quota on a tmp directory filled the cluster |
| What worked? | Alert fired, runbook was clear |
| What to change? | Add quotas, alert at 75%, update runbook |
Practice: Run a game day every quarter: kill the active NameNode, fill a test disk, expire a certificate in the lab. Teams that practise recover faster.
Conclusion
Combine monitoring with a daily routine, severity-based alerts, tested runbooks, controlled changes and blameless reviews. This is what separates a reliable platform from a fragile one.
Quick Summary: routine + alerts + runbooks + change control + reviews.

