From 1faaca69298c638ec78599542e75e40edb2ff48f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B8ren=20Louv-Jansen?= Date: Mon, 3 Dec 2018 15:24:14 +0100 Subject: [PATCH] [6.5] [APM] Move impact calculation to Elasticsearch (#26443) --- .../apm/server/lib/helpers/transaction_group_query.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/apm/server/lib/helpers/transaction_group_query.ts b/x-pack/plugins/apm/server/lib/helpers/transaction_group_query.ts index db7b65c646870..527a175b0b29f 100644 --- a/x-pack/plugins/apm/server/lib/helpers/transaction_group_query.ts +++ b/x-pack/plugins/apm/server/lib/helpers/transaction_group_query.ts @@ -23,6 +23,7 @@ export interface ITransactionGroupBucket { '95.0': number; }; }; + sum: { value: number }; sample: { hits: { hits: Array<{ @@ -36,7 +37,7 @@ export const TRANSACTION_GROUP_AGGREGATES = { transactions: { terms: { field: `${TRANSACTION_NAME}.keyword`, - order: { avg: 'desc' }, + order: { sum: 'desc' }, size: 100 }, aggs: { @@ -47,7 +48,8 @@ export const TRANSACTION_GROUP_AGGREGATES = { } }, avg: { avg: { field: TRANSACTION_DURATION } }, - p95: { percentiles: { field: TRANSACTION_DURATION, percents: [95] } } + p95: { percentiles: { field: TRANSACTION_DURATION, percents: [95] } }, + sum: { sum: { field: TRANSACTION_DURATION } } } } }; @@ -78,7 +80,7 @@ export function prepareTransactionGroups({ const results = buckets.map((bucket: ITransactionGroupBucket) => { const averageResponseTime = bucket.avg.value; const transactionsPerMinute = bucket.doc_count / minutes; - const impact = Math.round(averageResponseTime * transactionsPerMinute); + const impact = bucket.sum.value; const sample = bucket.sample.hits.hits[0]._source; return {