Hadoop Metrics and JMX: What to Watch on HDFS and YARN

Big Data and Hadoop Administrator 14 min min read Updated: Nov 17, 2026 Intermediate
Hadoop Metrics and JMX: What to Watch on HDFS and YARN
Intermediate Topic 1 of 4

Where Hadoop Publishes Metrics

SourceHow to read
Web UINameNode :9870, ResourceManager :8088 (human friendly)
JMX JSONhttp://host:9870/jmx on every daemon (machine friendly)
REST APIsResourceManager /ws/v1/cluster/..., WebHDFS, NodeManager /ws/v1/node
metrics2 sinksFile, Ganglia, Graphite, Prometheus-style sinks (config file)
Logs and audit logsEvent history and who did what

Query JMX with curl

bash # list all beans curl -s http://nn1:9870/jmx | jq '.beans[].name' | head -40 # NameNode summary: capacity, files, blocks curl -s 'http://nn1:9870/jmx?qry=Hadoop:service=NameNode,name=FSNamesystem' | jq '.beans[0] | {CapacityTotalGB, CapacityUsedGB, CapacityRemainingGB, FilesTotal, BlocksTotal, MissingBlocks, UnderReplicatedBlocks, CorruptBlocks, PendingReplicationBlocks}' # HA state and safe mode curl -s 'http://nn1:9870/jmx?qry=Hadoop:service=NameNode,name=NameNodeStatus' | jq '.beans[0].State' curl -s 'http://nn1:9870/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo' | jq '.beans[0] | {Safemode, LiveNodes, DeadNodes, NumberOfMissingBlocks}' # in secure clusters add: --negotiate -u : --cacert ca.pem and use https://...:9871

The Metrics That Matter: HDFS

MetricMeaningAlert idea
MissingBlocksBlocks with no replica> 0 critical
CorruptBlocksAll replicas corrupt> 0 critical
UnderReplicatedBlocksFewer replicas than neededRising for > 30 min
CapacityRemaining / used percentFree spaceUsed > 75% warn, 85% crit
Live / dead DataNodesNode healthAny new dead node
FilesTotal, BlocksTotalNamespace growthTrend vs heap size
RpcQueueTimeAvgTime, CallQueueLengthNameNode RPC overloadQueue time > 10 ms avg, queue length growing
Heap used and GC pause timeMemory pressureGC pause > 5 s
LastCheckpointTime / TransactionsSinceLastCheckpointCheckpoint delayNo checkpoint for 2x period
Safemode stateRead-only modeON outside startup

The Metrics That Matter: YARN

bash curl -s http://rm1:8088/ws/v1/cluster/metrics | jq '.clusterMetrics | {appsPending, appsRunning, appsFailed, availableMB, allocatedMB, totalMB, availableVirtualCores, activeNodes, unhealthyNodes, lostNodes, decommissionedNodes}' curl -s 'http://rm1:8088/ws/v1/cluster/apps?states=RUNNING&limit=5' | jq '.apps.app[] | {id, user, queue, elapsedTime, allocatedMB}' curl -s http://rm1:8088/ws/v1/cluster/scheduler | jq '.scheduler.schedulerInfo.queues.queue[] | {queueName, usedCapacity, capacity}'
MetricAlert idea
unhealthyNodes, lostNodes> 0 for several minutes
appsPendingGrowing: cluster or queue is full
Memory allocated percent> 90% for long periods means capacity shortage
Application failure rateSpike after a change
RM HA stateBoth standby, or flapping

Daemon Health: JVM Metrics

  • Heap and non-heap memory, GC count and time (java.lang:type=GarbageCollector)
  • Thread count and open file descriptors
  • Process uptime (a recent restart may mean a crash loop)

A Tiny Health Check Script

bash #!/bin/bash # hdfs-health.sh : exit 0 healthy, 1 warning, 2 critical (Nagios style) NN=${1:-nn1.example.com} J=$(curl -s --max-time 10 "http://$NN:9870/jmx?qry=Hadoop:service=NameNode,name=FSNamesystem") [ -z "$J" ] && { echo "CRITICAL: cannot read JMX"; exit 2; } MISSING=$(echo "$J" | jq '.beans[0].MissingBlocks') UNDER=$(echo "$J" | jq '.beans[0].UnderReplicatedBlocks') USED=$(echo "$J" | jq '.beans[0] | (.CapacityUsed / .CapacityTotal * 100) | floor') [ "$MISSING" -gt 0 ] && { echo "CRITICAL: $MISSING missing blocks"; exit 2; } [ "$USED" -ge 85 ] && { echo "CRITICAL: HDFS ${USED}% used"; exit 2; } [ "$UNDER" -gt 1000 ] || [ "$USED" -ge 75 ] && { echo "WARNING: under-replicated=$UNDER used=${USED}%"; exit 1; } echo "OK: used=${USED}% under=$UNDER"; exit 0

metrics2 Sinks

ini # hadoop-metrics2.properties *.sink.file.class=org.apache.hadoop.metrics2.sink.FileSink namenode.sink.file.filename=/var/log/hadoop/namenode-metrics.out *.period=60
Practical choice: For real monitoring use a time-series system (the next lesson uses Prometheus and Grafana). The JMX endpoint is perfect for quick checks, scripts and debugging.
Know your baseline: Alerts based on fixed numbers fail when workloads change. Record normal ranges for RPC latency, block count growth and daily capacity growth, then alert on changes.

Conclusion

Every Hadoop daemon exposes JMX at /jmx, and the ResourceManager has REST APIs. Watch missing, corrupt and under-replicated blocks, capacity, RPC queue time, heap and GC, unhealthy nodes and pending apps.

Quick Summary: /jmx + RM REST; MissingBlocks > 0 = critical; capacity and RPC latency.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators