[APM] Add range query to terms enum call (#162614)

Closes https://github.com/elastic/kibana/issues/159202
This commit is contained in:
Achyut Jhunjhunwala 2023-07-27 13:49:05 +02:00 committed by GitHub
parent 7277dba30f
commit 28800ef35e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 27 additions and 3 deletions

View file

@ -112,12 +112,14 @@ export function ServicesTable() {
environment,
kuery,
indexLifecyclePhase,
start,
end,
},
},
});
}
},
[environment, kuery, indexLifecyclePhase, useOptimizedSorting]
[useOptimizedSorting, environment, kuery, indexLifecyclePhase, start, end]
);
const serviceStatisticsFetch = useProgressiveFetcher(

View file

@ -15,10 +15,14 @@ export async function getServiceNamesFromTermsEnum({
apmEventClient,
environment,
maxNumberOfServices,
start,
end,
}: {
apmEventClient: APMEventClient;
environment: Environment;
maxNumberOfServices: number;
start: number;
end: number;
}) {
if (environment !== ENVIRONMENT_ALL.value) {
return [];
@ -36,6 +40,15 @@ export async function getServiceNamesFromTermsEnum({
},
size: maxNumberOfServices,
field: SERVICE_NAME,
index_filter: {
range: {
['@timestamp']: {
gte: start,
lte: end,
format: 'epoch_millis',
},
},
},
}
);

View file

@ -323,7 +323,12 @@ const storageExplorerGetServices = createApmServerRoute({
tags: ['access:apm'],
},
params: t.type({
query: t.intersection([indexLifecyclePhaseRt, environmentRt, kueryRt]),
query: t.intersection([
indexLifecyclePhaseRt,
environmentRt,
kueryRt,
rangeRt,
]),
}),
handler: async (
resources
@ -333,7 +338,7 @@ const storageExplorerGetServices = createApmServerRoute({
}>;
}> => {
const {
query: { environment, kuery, indexLifecyclePhase },
query: { environment, kuery, indexLifecyclePhase, start, end },
} = resources.params;
if (
@ -352,6 +357,8 @@ const storageExplorerGetServices = createApmServerRoute({
apmEventClient,
environment,
maxNumberOfServices: 500,
start,
end,
});
return {

View file

@ -37,6 +37,8 @@ export default function ApiTest({ getService }: FtrProviderContext) {
environment,
kuery,
indexLifecyclePhase,
start,
end,
},
},
});