From 7c4ba9f92caaae7a6cc803eecb629e15ee7013ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Fri, 21 Aug 2020 20:55:21 +0100 Subject: [PATCH] [7.x] Fix returned payload by "search" usage collector (#75340) (#75677) Co-authored-by: Elastic Machine Co-authored-by: Elastic Machine --- src/plugins/data/server/search/collectors/fetch.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins/data/server/search/collectors/fetch.ts b/src/plugins/data/server/search/collectors/fetch.ts index ee29607b63ede..3551767eab017 100644 --- a/src/plugins/data/server/search/collectors/fetch.ts +++ b/src/plugins/data/server/search/collectors/fetch.ts @@ -19,14 +19,18 @@ import { Observable } from 'rxjs'; import { first } from 'rxjs/operators'; -import { LegacyAPICaller, SharedGlobalConfig } from '../../../../../core/server'; +import { LegacyAPICaller, SharedGlobalConfig } from 'kibana/server'; import { Usage } from './register'; +interface SearchTelemetrySavedObject { + 'search-telemetry': Usage; +} + export function fetchProvider(config$: Observable) { return async (callCluster: LegacyAPICaller): Promise => { const config = await config$.pipe(first()).toPromise(); - const response = await callCluster('search', { + const response = await callCluster('search', { index: config.kibana.index, body: { query: { term: { type: { value: 'search-telemetry' } } }, @@ -35,7 +39,7 @@ export function fetchProvider(config$: Observable) { }); return response.hits.hits.length - ? (response.hits.hits[0]._source as Usage) + ? response.hits.hits[0]._source['search-telemetry'] : { successCount: 0, errorCount: 0,