From 1628ce449c31bd98477e5f0c10eed286374a0e75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez?= Date: Fri, 10 Jul 2020 11:54:39 +0200 Subject: [PATCH] [7.x] [Logs UI] Process long running requests in logs overview (#70791) (#70978) Co-authored-by: Elastic Machine --- .../infra/public/utils/logs_overview_fetchers.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts b/x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts index ec203f451bc14..5a0a996287959 100644 --- a/x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts +++ b/x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts @@ -6,6 +6,7 @@ import { encode } from 'rison-node'; import { i18n } from '@kbn/i18n'; +import { SearchResponse } from 'src/plugins/data/public'; import { DEFAULT_SOURCE_ID } from '../../common/constants'; import { InfraClientCoreSetup, InfraClientStartDeps } from '../types'; import { @@ -90,6 +91,8 @@ async function fetchLogsOverview( dataPlugin: InfraClientStartDeps['data'] ): Promise { return new Promise((resolve, reject) => { + let esResponse: SearchResponse = {}; + dataPlugin.search .search({ params: { @@ -102,14 +105,15 @@ async function fetchLogsOverview( }, }) .subscribe( - (response) => { - if (response.rawResponse.aggregations) { - resolve(processLogsOverviewAggregations(response.rawResponse.aggregations)); + (response) => (esResponse = response.rawResponse), + (error) => reject(error), + () => { + if (esResponse.aggregations) { + resolve(processLogsOverviewAggregations(esResponse.aggregations)); } else { resolve({ stats: {}, series: {} }); } - }, - (error) => reject(error) + } ); }); }