Skip to content

Commit e41692e

Browse files
author
Alejandro Fernández
authored
[Logs UI] Process long running requests in logs overview (#70791)
1 parent 49da11f commit e41692e

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

x-pack/plugins/infra/public/utils/logs_overview_fetchers.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import { encode } from 'rison-node';
88
import { i18n } from '@kbn/i18n';
9+
import { SearchResponse } from 'src/plugins/data/public';
910
import { DEFAULT_SOURCE_ID } from '../../common/constants';
1011
import { InfraClientCoreSetup, InfraClientStartDeps } from '../types';
1112
import {
@@ -89,9 +90,10 @@ async function fetchLogsOverview(
8990
params: FetchDataParams,
9091
dataPlugin: InfraClientStartDeps['data']
9192
): Promise<StatsAndSeries> {
92-
const esSearcher = dataPlugin.search.getSearchStrategy('es');
9393
return new Promise((resolve, reject) => {
94-
esSearcher
94+
let esResponse: SearchResponse = {};
95+
96+
dataPlugin.search
9597
.search({
9698
params: {
9799
index: logParams.index,
@@ -103,14 +105,15 @@ async function fetchLogsOverview(
103105
},
104106
})
105107
.subscribe(
106-
(response) => {
107-
if (response.rawResponse.aggregations) {
108-
resolve(processLogsOverviewAggregations(response.rawResponse.aggregations));
108+
(response) => (esResponse = response.rawResponse),
109+
(error) => reject(error),
110+
() => {
111+
if (esResponse.aggregations) {
112+
resolve(processLogsOverviewAggregations(esResponse.aggregations));
109113
} else {
110114
resolve({ stats: {}, series: {} });
111115
}
112-
},
113-
(error) => reject(error)
116+
}
114117
);
115118
});
116119
}

0 commit comments

Comments
 (0)