Skip to content

Commit

Permalink
[Stack Monitoring] Fix shard size alerts (#114357)
Browse files Browse the repository at this point in the history
* [Stack Monitoring] Fix shard size alerts

* Removing the source filter for source_node.*

* Removing superfluous types

* Removing superfluous nodeId and nodeName from test
  • Loading branch information
simianhacker authored Oct 13, 2021
1 parent 5de36a8 commit 6d24de9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
4 changes: 3 additions & 1 deletion x-pack/plugins/monitoring/common/types/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,11 @@ export interface CCRReadExceptionsUIMeta extends CCRReadExceptionsStats {
itemLabel: string;
}

export interface IndexShardSizeStats extends AlertNodeStats {
export interface IndexShardSizeStats {
shardIndex: string;
shardSize: number;
clusterUuid: string;
ccs?: string;
}

export interface IndexShardSizeUIMeta extends IndexShardSizeStats {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,10 @@ describe('LargeShardSizeRule', () => {
const shardSize = 0;
const clusterUuid = 'abc123';
const clusterName = 'testCluster';
const nodeId = 'myNodeId';
const nodeName = 'myNodeName';
const stat = {
shardIndex,
shardSize,
clusterUuid,
nodeId,
nodeName,
};

const replaceState = jest.fn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@ import { ElasticsearchIndexStats, ElasticsearchResponseHit } from '../../../comm
import { ESGlobPatterns, RegExPatterns } from '../../../common/es_glob_patterns';
import { Globals } from '../../static_globals';

interface SourceNode {
name: string;
uuid: string;
}
type TopHitType = ElasticsearchResponseHit & {
_source: { index_stats?: Partial<ElasticsearchIndexStats>; source_node?: SourceNode };
_source: { index_stats?: Partial<ElasticsearchIndexStats> };
};

const memoizedIndexPatterns = (globPatterns: string) => {
Expand Down Expand Up @@ -90,8 +86,6 @@ export async function fetchIndexShardSize(
'_index',
'index_stats.shards.primaries',
'index_stats.primaries.store.size_in_bytes',
'source_node.name',
'source_node.uuid',
],
},
size: 1,
Expand Down Expand Up @@ -135,10 +129,10 @@ export async function fetchIndexShardSize(
}
const {
_index: monitoringIndexName,
_source: { source_node: sourceNode, index_stats: indexStats },
_source: { index_stats: indexStats },
} = topHit;

if (!indexStats || !indexStats.primaries || !sourceNode) {
if (!indexStats || !indexStats.primaries) {
continue;
}

Expand All @@ -151,7 +145,6 @@ export async function fetchIndexShardSize(
* We can only calculate the average primary shard size at this point, since we don't have
* data (in .monitoring-es* indices) to give us individual shards. This might change in the future
*/
const { name: nodeName, uuid: nodeId } = sourceNode;
const avgShardSize = primaryShardSizeBytes / totalPrimaryShards;
if (avgShardSize < thresholdBytes) {
continue;
Expand All @@ -161,8 +154,6 @@ export async function fetchIndexShardSize(
shardIndex,
shardSize,
clusterUuid,
nodeName,
nodeId,
ccs: monitoringIndexName.includes(':') ? monitoringIndexName.split(':')[0] : undefined,
});
}
Expand Down

0 comments on commit 6d24de9

Please sign in to comment.