diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTiersUsageTransportAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTiersUsageTransportAction.java index b7120f213cb15..92923ff99f29e 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTiersUsageTransportAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/DataTiersUsageTransportAction.java @@ -206,7 +206,8 @@ private static void aggregateDataTierShardStats(NodeStats nodeStats, Index index accumulator.docCount += shardStat.getTotal().getDocs().getCount(); // Accumulate stats about started shards - if (node.getByShardId(shardStat.getShardId()).state() == ShardRoutingState.STARTED) { + ShardRouting shardRouting = node.getByShardId(shardStat.getShardId()); + if (shardRouting != null && shardRouting.state() == ShardRoutingState.STARTED) { accumulator.totalShardCount += 1; // Accumulate stats about started primary shards