Skip to content

Commit

Permalink
Addressed cr feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
igoristic committed Apr 12, 2021
1 parent 3be20e9 commit 019e9c9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/user/monitoring/kibana-alerts.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ by running checks on a schedule time of 1 minute with a re-notify interval of 6
== Large shard size

This alert is triggered if a large average shard size (across associated primaries) is found on any of the
specified index patterns. The trigger condition is met if an index's (primary average) shard size is
specified index patterns. The trigger condition is met if an index's average shard size is
55gb or higher in the last 5 minutes. The alert is grouped across all indices that match
the default patter of `*` by running checks on a schedule time of 1 minute with a re-notify
interval of 12 hours.
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/monitoring/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ export const ALERT_DETAILS = {
paramDetails: {
threshold: {
label: i18n.translate('xpack.monitoring.alerts.shardSize.paramDetails.threshold.label', {
defaultMessage: `Notify when primary average shard size exceeds this value`,
defaultMessage: `Notify when average shard size exceeds this value`,
}),
type: AlertParamType.Number,
append: 'GB',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ export class LargeShardSizeAlert extends BaseAlert {
description: i18n.translate(
'xpack.monitoring.alerts.shardSize.actionVariables.shardIndex',
{
defaultMessage:
'List of indices which are experiencing large (primary average) shard size.',
defaultMessage: 'List of indices which are experiencing large average shard size.',
}
),
},
Expand Down Expand Up @@ -101,7 +100,7 @@ export class LargeShardSizeAlert extends BaseAlert {
const { shardIndex, shardSize } = item.meta as IndexShardSizeUIMeta;
return {
text: i18n.translate('xpack.monitoring.alerts.shardSize.ui.firingMessage', {
defaultMessage: `The following index: #start_link{shardIndex}#end_link has a large (primary average) shard size of: {shardSize}GB at #absolute`,
defaultMessage: `The following index: #start_link{shardIndex}#end_link has a large average shard size of: {shardSize}GB at #absolute`,
values: {
shardIndex,
shardSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,16 @@ export async function fetchIndexShardSize(
}

const { primaries: totalPrimaryShards } = indexStats.shards;
const { size_in_bytes: primaryShardSizeBytes = 0 } = indexStats.primaries.store!;
const { size_in_bytes: primaryShardSizeBytes = 0 } = indexStats.primaries.store || {};
if (!primaryShardSizeBytes) {
continue;
}
/**
* 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 ? primaryShardSizeBytes / totalPrimaryShards : 0;
const avgShardSize = primaryShardSizeBytes / totalPrimaryShards;
const shardSize = +(avgShardSize / gbMultiplier).toFixed(2);
if (shardSize < thresholdGB) {
continue;
Expand Down

0 comments on commit 019e9c9

Please sign in to comment.