From ef76de16a2cc2086fe026278dc691415e8499513 Mon Sep 17 00:00:00 2001 From: Igor Zaytsev Date: Tue, 15 Dec 2020 16:29:45 -0500 Subject: [PATCH] CR feedback --- .../server/alerts/ccr_read_exceptions_alert.ts | 15 ++++++++++----- .../lib/alerts/fetch_ccr_read_exceptions.ts | 11 ++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/monitoring/server/alerts/ccr_read_exceptions_alert.ts b/x-pack/plugins/monitoring/server/alerts/ccr_read_exceptions_alert.ts index c4a335f293d87..9e48af9aad5e5 100644 --- a/x-pack/plugins/monitoring/server/alerts/ccr_read_exceptions_alert.ts +++ b/x-pack/plugins/monitoring/server/alerts/ccr_read_exceptions_alert.ts @@ -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'; @@ -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 ); @@ -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', { @@ -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, }, } diff --git a/x-pack/plugins/monitoring/server/lib/alerts/fetch_ccr_read_exceptions.ts b/x-pack/plugins/monitoring/server/lib/alerts/fetch_ccr_read_exceptions.ts index 5ecb8bce5aad5..c8933a7cd14a9 100644 --- a/x-pack/plugins/monitoring/server/lib/alerts/fetch_ccr_read_exceptions.ts +++ b/x-pack/plugins/monitoring/server/lib/alerts/fetch_ccr_read_exceptions.ts @@ -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 { const params = { @@ -25,7 +26,9 @@ export async function fetchCCRReadExceptions( nested: { path: 'ccr_stats.read_exceptions', query: { - match_all: {}, + exists: { + field: 'ccr_stats.read_exceptions.exception', + }, }, }, }, @@ -37,7 +40,9 @@ export async function fetchCCRReadExceptions( { range: { timestamp: { - gte: `now-${duration}`, + format: 'epoch_millis', + gte: startMs, + lte: endMs, }, }, },