Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add null check for shard stats to data tier telemetry #75185

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
import org.elasticsearch.action.admin.indices.stats.IndexShardStats;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterState;
Expand Down Expand Up @@ -108,16 +109,19 @@ private DataTiersFeatureSetUsage.TierSpecificStats calculateStats(List<NodeStats
.collect(Collectors.toSet());
indexCount += indicesOnNode.size();
indicesOnNode.forEach(index -> {
nodeStats.getIndices().getShardStats(index).stream()
.filter(shardStats -> shardStats.getPrimary().getStore() != null)
.forEach(shardStats -> {
StoreStats primaryStoreStats = shardStats.getPrimary().getStore();
// If storeStats is null, it means this is not a replica
primaryShardCount.incrementAndGet();
long primarySize = primaryStoreStats.getSizeInBytes();
primaryByteCount.addAndGet(primarySize);
valueSketch.add(primarySize);
});
final List<IndexShardStats> allShardStats = nodeStats.getIndices().getShardStats(index);
if (allShardStats != null) {
allShardStats.stream()
.filter(shardStats -> shardStats.getPrimary().getStore() != null)
.forEach(shardStats -> {
StoreStats primaryStoreStats = shardStats.getPrimary().getStore();
// If storeStats is null, it means this is not a replica
primaryShardCount.incrementAndGet();
long primarySize = primaryStoreStats.getSizeInBytes();
primaryByteCount.addAndGet(primarySize);
valueSketch.add(primarySize);
});
}
});
}
}
Expand Down