Skip to content

Commit

Permalink
CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
igoristic committed Dec 15, 2020
1 parent 55a5adc commit ef76de1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
import { fetchCCRReadExceptions } from '../lib/alerts/fetch_ccr_read_exceptions';
import { getCcsIndexPattern } from '../lib/alerts/get_ccs_index_pattern';
import { AlertMessageTokenType, AlertSeverity } from '../../common/enums';
import { parseDuration } from '../../../alerts/common/parse_duration';
import { SanitizedAlert } from '../../../alerts/common';
import { AlertingDefaults, createLink } from './alert_helpers';
import { appendMetricbeatIndex } from '../lib/alerts/append_mb_index';
Expand Down Expand Up @@ -74,11 +75,15 @@ export class CCRReadExceptionsAlert extends BaseAlert {
if (availableCcs) {
esIndexPattern = getCcsIndexPattern(esIndexPattern, availableCcs);
}
const { duration } = params;
const { duration: durationString } = params;
const duration = parseDuration(durationString);
const endMs = +new Date();
const startMs = endMs - duration;
const stats = await fetchCCRReadExceptions(
callCluster,
esIndexPattern,
duration as string,
startMs,
endMs,
Globals.app.config.ui.max_bucket_size
);

Expand Down Expand Up @@ -212,7 +217,7 @@ export class CCRReadExceptionsAlert extends BaseAlert {
'xpack.monitoring.alerts.ccrReadExceptions.shortAction',
{
defaultMessage:
'Verify follower/leader index relationships across the affected remote clusters.',
'Verify follower and leader index relationships across the affected remote clusters.',
}
);
const fullActionText = i18n.translate('xpack.monitoring.alerts.ccrReadExceptions.fullAction', {
Expand Down Expand Up @@ -240,10 +245,10 @@ export class CCRReadExceptionsAlert extends BaseAlert {
const internalFullMessage = i18n.translate(
'xpack.monitoring.alerts.ccrReadExceptions.firing.internalFullMessage',
{
defaultMessage: `CCR read exceptions alert is firing for the following remote clusters: {remoteClustersList}. Current 'follower_index' indices are affected: {followerIndicesList}. {shortActionText}`,
defaultMessage: `CCR read exceptions alert is firing for the following remote clusters: {remoteClustersList}. Current 'follower_index' indices are affected: {followerIndicesList}. {action}`,
values: {
action,
remoteClustersList,
shortActionText,
followerIndicesList,
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { CCRReadExceptionsStats } from '../../../common/types/alerts';
export async function fetchCCRReadExceptions(
callCluster: any,
index: string,
duration: string,
startMs: number,
endMs: number,
size: number
): Promise<CCRReadExceptionsStats[]> {
const params = {
Expand All @@ -25,7 +26,9 @@ export async function fetchCCRReadExceptions(
nested: {
path: 'ccr_stats.read_exceptions',
query: {
match_all: {},
exists: {
field: 'ccr_stats.read_exceptions.exception',
},
},
},
},
Expand All @@ -37,7 +40,9 @@ export async function fetchCCRReadExceptions(
{
range: {
timestamp: {
gte: `now-${duration}`,
format: 'epoch_millis',
gte: startMs,
lte: endMs,
},
},
},
Expand Down

0 comments on commit ef76de1

Please sign in to comment.