diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/index.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/index.ts index 559612cb07ead..b14de60d00f12 100644 --- a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/index.ts +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/index.ts @@ -17,7 +17,11 @@ type ISavedObjectsClient = Pick; type TelemetryTaskExecutor = (params: { indices: ApmIndicesConfig; - search( + search< + TSearchRequest extends ESSearchRequest & { index: string | string[] } & { + body: { timeout: string }; + } + >( params: TSearchRequest ): Promise>; indicesStats( diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.test.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.test.ts index b69aa1e6e0196..5f0c5e2c7ded4 100644 --- a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.test.ts +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.test.ts @@ -433,7 +433,7 @@ describe('data telemetry collection tasks', () => { } }); - expect(await task?.executor({ search } as any)).toEqual({ + expect(await task?.executor({ search, indices } as any)).toEqual({ cardinality: { client: { geo: { country_iso_code: { rum: { '1d': 5 } } } }, transaction: { name: { all_agents: { '1d': 3 }, rum: { '1d': 1 } } }, diff --git a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts index d9a695ff1f4e4..7283761c4b4bd 100644 --- a/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts +++ b/x-pack/plugins/apm/server/lib/apm_telemetry/collect_data_telemetry/tasks.ts @@ -147,6 +147,7 @@ export const tasks: TelemetryTask[] = [ await search({ index: indices.transaction, body: { + timeout, query: { bool: { filter: [ @@ -354,6 +355,7 @@ export const tasks: TelemetryTask[] = [ const response = await search({ index: [indices.transaction], body: { + timeout, query: { bool: { filter: [{ range: { '@timestamp': { gte: 'now-1d' } } }], @@ -1031,8 +1033,9 @@ export const tasks: TelemetryTask[] = [ }, { name: 'cardinality', - executor: async ({ search }) => { + executor: async ({ indices, search }) => { const allAgentsCardinalityResponse = await search({ + index: [indices.transaction], body: { size: 0, timeout, @@ -1057,6 +1060,7 @@ export const tasks: TelemetryTask[] = [ }); const rumAgentCardinalityResponse = await search({ + index: [indices.transaction], body: { size: 0, timeout,