From 57453f1709970b2bdf219b5bef8f408fb0a9ec41 Mon Sep 17 00:00:00 2001 From: ymao1 Date: Mon, 1 Feb 2021 10:17:59 -0500 Subject: [PATCH] Some fixes from backport (#89746) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- .../stack_alerts/common/build_sorted_events_query.ts | 4 ++-- .../server/alert_types/es_query/alert_type.ts | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/stack_alerts/common/build_sorted_events_query.ts b/x-pack/plugins/stack_alerts/common/build_sorted_events_query.ts index 92425433bf81..b9a65cf1a748 100644 --- a/x-pack/plugins/stack_alerts/common/build_sorted_events_query.ts +++ b/x-pack/plugins/stack_alerts/common/build_sorted_events_query.ts @@ -87,7 +87,7 @@ export const buildSortedEventsQuery = ({ ...searchQuery.body, search_after: [searchAfterSortId], }, - }; + } as ESSearchRequest; } - return searchQuery; + return searchQuery as ESSearchRequest; }; diff --git a/x-pack/plugins/stack_alerts/server/alert_types/es_query/alert_type.ts b/x-pack/plugins/stack_alerts/server/alert_types/es_query/alert_type.ts index b8190340c4d6..a0da622a73ce 100644 --- a/x-pack/plugins/stack_alerts/server/alert_types/es_query/alert_type.ts +++ b/x-pack/plugins/stack_alerts/server/alert_types/es_query/alert_type.ts @@ -175,7 +175,17 @@ export function getAlertType( { bool: { must_not: [ - { bool: { filter: [{ range: { [params.timeField]: { lte: timestamp } } }] } }, + { + bool: { + filter: [ + { + range: { + [params.timeField]: { lte: new Date(timestamp).toISOString() }, + }, + }, + ], + }, + }, ], }, },