Skip to content

Commit

Permalink
[7.x] [Logs UI] Process long running requests in logs overview (#70791)…
Browse files Browse the repository at this point in the history
… (#70978)

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
Alejandro Fernández and elasticmachine authored Jul 10, 2020
1 parent 0f6fd7f commit 1628ce4
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -90,6 +91,8 @@ async function fetchLogsOverview(
dataPlugin: InfraClientStartDeps['data']
): Promise<StatsAndSeries> {
return new Promise((resolve, reject) => {
let esResponse: SearchResponse = {};

dataPlugin.search
.search({
params: {
Expand All @@ -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)
}
);
});
}
Expand Down

0 comments on commit 1628ce4

Please sign in to comment.