Skip to content

Commit

Permalink
[Stack Monitoring] Use doc ID to deduplicate shard allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
miltonhultgren committed Oct 25, 2022
1 parent 37454b7 commit 21ea2ba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions x-pack/plugins/monitoring/common/types/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface ElasticsearchResponse {
}

export interface ElasticsearchResponseHit {
_id: string;
_index: string;
_source: ElasticsearchSource;
inner_hits?: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ export function handleResponse(response: ElasticsearchResponse) {
mbShard?.shard?.relocating_node?.id ?? legacyShard?.relocating_node ?? null;
const node = mbShard?.node?.id ?? legacyShard?.node;
// note: if the request is for a node, then it's enough to deduplicate without primary, but for indices it displays both
const shardId = `${index}-${shardNumber}-${primary}-${relocatingNode}-${node}`;

if (!uniqueShards.has(shardId)) {
if (!uniqueShards.has(hit._id)) {
// @ts-ignore
shards.push({
index,
Expand All @@ -48,7 +47,7 @@ export function handleResponse(response: ElasticsearchResponse) {
shard: shardNumber,
state: legacyShard?.state ?? mbShard?.shard?.state,
});
uniqueShards.add(shardId);
uniqueShards.add(hit._id);
}
}

Expand Down

0 comments on commit 21ea2ba

Please sign in to comment.