Skip to content

Commit

Permalink
CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
igoristic committed Oct 2, 2020
1 parent f08e5f6 commit 509be7e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 8 additions & 2 deletions x-pack/plugins/monitoring/server/alerts/memory_usage_alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { RawAlertInstance } from '../../../alerts/common';
import { CommonAlertFilter, CommonAlertParams, CommonAlertParamDetail } from '../../common/types';
import { AlertingDefaults, createLink } from './alerts_common';
import { appendMetricbeatIndex } from '../lib/alerts/append_mb_index';
import { parseDuration } from '../../../alerts/common/parse_duration';

interface ParamDetails {
[key: string]: CommonAlertParamDetail;
Expand Down Expand Up @@ -54,7 +55,7 @@ export class MemoryUsageAlert extends BaseAlert {
public label = MemoryUsageAlert.LABEL;

protected defaultParams = {
threshold: 90,
threshold: 85,
duration: '5m',
};

Expand Down Expand Up @@ -86,11 +87,16 @@ export class MemoryUsageAlert extends BaseAlert {
esIndexPattern = getCcsIndexPattern(esIndexPattern, availableCcs);
}
const { duration, threshold } = params;
const parsedDuration = parseDuration(duration as string);
const endMs = +new Date();
const startMs = endMs - parsedDuration;

const stats = await fetchMemoryUsageNodeStats(
callCluster,
clusters,
esIndexPattern,
duration as string,
startMs,
endMs,
this.config.ui.max_bucket_size
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export async function fetchMemoryUsageNodeStats(
callCluster: any,
clusters: AlertCluster[],
index: string,
duration: string,
startMs: number,
endMs: number,
size: number
): Promise<AlertMemoryUsageNodeStats[]> {
const clustersIds = clusters.map((cluster) => cluster.clusterUuid);
Expand All @@ -36,7 +37,9 @@ export async function fetchMemoryUsageNodeStats(
{
range: {
timestamp: {
gte: `now-${duration}`,
format: 'epoch_millis',
gte: startMs,
lte: endMs,
},
},
},
Expand Down

0 comments on commit 509be7e

Please sign in to comment.