From 18b2b5c3715182b3436a0314227bc52ffcc69993 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 4 Oct 2024 17:28:53 +1000 Subject: [PATCH] [8.x] [ES|QL] Pass the took time to the inspector (#194806) (#194897) # Backport This will backport the following commits from `main` to `8.x`: - [[ES|QL] Pass the took time to the inspector (#194806)](https://github.com/elastic/kibana/pull/194806) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Stratoula Kalafateli --- packages/kbn-es-types/src/search.ts | 1 + .../data/common/search/expressions/esql.ts | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/packages/kbn-es-types/src/search.ts b/packages/kbn-es-types/src/search.ts index 553401b19b986..3e67208bc2793 100644 --- a/packages/kbn-es-types/src/search.ts +++ b/packages/kbn-es-types/src/search.ts @@ -681,6 +681,7 @@ export interface ESQLSearchResponse { // while columns only the available ones (non nulls) all_columns?: ESQLColumn[]; values: ESQLRow[]; + took?: number; } export interface ESQLSearchParams { diff --git a/src/plugins/data/common/search/expressions/esql.ts b/src/plugins/data/common/search/expressions/esql.ts index b076545d537c4..b6cb039683c9b 100644 --- a/src/plugins/data/common/search/expressions/esql.ts +++ b/src/plugins/data/common/search/expressions/esql.ts @@ -271,6 +271,22 @@ export const getEsqlFn = ({ getStartDependencies }: EsqlFnArguments) => { defaultMessage: 'The number of documents returned by the query.', }), }, + ...(rawResponse?.took && { + queryTime: { + label: i18n.translate('data.search.es_search.queryTimeLabel', { + defaultMessage: 'Query time', + }), + value: i18n.translate('data.search.es_search.queryTimeValue', { + defaultMessage: '{queryTime}ms', + values: { queryTime: rawResponse.took }, + }), + description: i18n.translate('data.search.es_search.queryTimeDescription', { + defaultMessage: + 'The time it took to process the query. ' + + 'Does not include the time to send the request or parse it in the browser.', + }), + }, + }), }) .json(params) .ok({ json: rawResponse, requestParams });