Skip to content

Commit

Permalink
[APM] Add range query to terms enum call (#162614)
Browse files Browse the repository at this point in the history
Closes #159202
  • Loading branch information
achyutjhunjhunwala authored Jul 27, 2023
1 parent 7277dba commit 28800ef
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 [];
Expand All @@ -36,6 +40,15 @@ export async function getServiceNamesFromTermsEnum({
},
size: maxNumberOfServices,
field: SERVICE_NAME,
index_filter: {
range: {
['@timestamp']: {
gte: start,
lte: end,
format: 'epoch_millis',
},
},
},
}
);

Expand Down
11 changes: 9 additions & 2 deletions x-pack/plugins/apm/server/routes/storage_explorer/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -333,7 +338,7 @@ const storageExplorerGetServices = createApmServerRoute({
}>;
}> => {
const {
query: { environment, kuery, indexLifecyclePhase },
query: { environment, kuery, indexLifecyclePhase, start, end },
} = resources.params;

if (
Expand All @@ -352,6 +357,8 @@ const storageExplorerGetServices = createApmServerRoute({
apmEventClient,
environment,
maxNumberOfServices: 500,
start,
end,
});

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export default function ApiTest({ getService }: FtrProviderContext) {
environment,
kuery,
indexLifecyclePhase,
start,
end,
},
},
});
Expand Down

0 comments on commit 28800ef

Please sign in to comment.