-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OBS]home page is showing incorrect value of APM throughput (tpm) (#9…
…5991) (#96217) * fixing obs transaction per minute value * addressing PR comments * fixing unit test * addressing PR comments Co-authored-by: Kibana Machine <[email protected]> Co-authored-by: Cauê Marcondes <[email protected]>
- Loading branch information
1 parent
328cc41
commit e3d0830
Showing
9 changed files
with
166 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 0 additions & 64 deletions
64
x-pack/plugins/apm/server/lib/observability_overview/get_transaction_coordinates.ts
This file was deleted.
Oops, something went wrong.
95 changes: 95 additions & 0 deletions
95
x-pack/plugins/apm/server/lib/observability_overview/get_transactions_per_minute.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { | ||
TRANSACTION_PAGE_LOAD, | ||
TRANSACTION_REQUEST, | ||
} from '../../../common/transaction_types'; | ||
import { TRANSACTION_TYPE } from '../../../common/elasticsearch_fieldnames'; | ||
import { rangeQuery } from '../../../server/utils/queries'; | ||
import { Setup, SetupTimeRange } from '../helpers/setup_request'; | ||
import { getProcessorEventForAggregatedTransactions } from '../helpers/aggregated_transactions'; | ||
import { calculateThroughput } from '../helpers/calculate_throughput'; | ||
import { withApmSpan } from '../../utils/with_apm_span'; | ||
|
||
export function getTransactionsPerMinute({ | ||
setup, | ||
bucketSize, | ||
searchAggregatedTransactions, | ||
}: { | ||
setup: Setup & SetupTimeRange; | ||
bucketSize: string; | ||
searchAggregatedTransactions: boolean; | ||
}) { | ||
return withApmSpan( | ||
'observability_overview_get_transactions_per_minute', | ||
async () => { | ||
const { apmEventClient, start, end } = setup; | ||
|
||
const { aggregations } = await apmEventClient.search({ | ||
apm: { | ||
events: [ | ||
getProcessorEventForAggregatedTransactions( | ||
searchAggregatedTransactions | ||
), | ||
], | ||
}, | ||
body: { | ||
size: 0, | ||
query: { | ||
bool: { | ||
filter: rangeQuery(start, end), | ||
}, | ||
}, | ||
aggs: { | ||
transactionType: { | ||
terms: { | ||
field: TRANSACTION_TYPE, | ||
}, | ||
aggs: { | ||
timeseries: { | ||
date_histogram: { | ||
field: '@timestamp', | ||
fixed_interval: bucketSize, | ||
min_doc_count: 0, | ||
}, | ||
aggs: { | ||
throughput: { rate: { unit: 'minute' as const } }, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
if (!aggregations || !aggregations.transactionType.buckets) { | ||
return { value: undefined, timeseries: [] }; | ||
} | ||
|
||
const topTransactionTypeBucket = | ||
aggregations.transactionType.buckets.find( | ||
({ key: transactionType }) => | ||
transactionType === TRANSACTION_REQUEST || | ||
transactionType === TRANSACTION_PAGE_LOAD | ||
) || aggregations.transactionType.buckets[0]; | ||
|
||
return { | ||
value: calculateThroughput({ | ||
start, | ||
end, | ||
value: topTransactionTypeBucket?.doc_count || 0, | ||
}), | ||
timeseries: | ||
topTransactionTypeBucket?.timeseries.buckets.map((bucket) => ({ | ||
x: bucket.key, | ||
y: bucket.throughput.value, | ||
})) || [], | ||
}; | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters