Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] fixes incorrect values in service overview throughput chart #89348

Merged
merged 9 commits into from
Jan 29, 2021
11 changes: 8 additions & 3 deletions x-pack/plugins/apm/server/lib/services/get_throughput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,17 @@ interface Options {

type ESResponse = PromiseReturnType<typeof fetcher>;

function transform(response: ESResponse) {
function transform(response: ESResponse, options: Options) {
const { end, start } = options.setup;
const deltaAsMinutes = (end - start) / 1000 / 60;
ogupte marked this conversation as resolved.
Show resolved Hide resolved
if (response.hits.total.value === 0) {
return [];
}
const buckets = response.aggregations?.throughput.buckets ?? [];
return buckets.map(({ key: x, doc_count: y }) => ({ x, y }));
return buckets.map(({ key: x, doc_count: y }) => ({
x,
y: y / deltaAsMinutes,
}));
}

async function fetcher({
Expand Down Expand Up @@ -82,6 +87,6 @@ async function fetcher({

export async function getThroughput(options: Options) {
return {
throughput: transform(await fetcher(options)),
throughput: transform(await fetcher(options), options),
};
}