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] Remove rate aggregations #112343

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
5d0d418
fixing rate aggregation bug
cauemarcondes Sep 15, 2021
b11a3ed
Merge branch '7.15' into apm-throughput-fix
kibanamachine Sep 15, 2021
cf1c1d4
fixing tests and i18n
cauemarcondes Sep 15, 2021
d8a7b3d
Merge branch 'apm-throughput-fix' of github.com:cauemarcondes/kibana …
cauemarcondes Sep 15, 2021
917d11d
fixing tests
cauemarcondes Sep 15, 2021
9d1b0c6
Merge branch '7.15' of github.com:elastic/kibana into apm-throughput-fix
cauemarcondes Sep 15, 2021
8074ded
putting back some code
cauemarcondes Sep 16, 2021
6b87f7c
fixing import path
cauemarcondes Sep 16, 2021
ffdfa37
Merge branch '7.15' into apm-throughput-fix
kibanamachine Sep 20, 2021
29d267d
addressing pr changes
cauemarcondes Sep 21, 2021
f9715a6
fixing prettier
cauemarcondes Sep 21, 2021
1863af6
renaming
cauemarcondes Sep 21, 2021
52082f2
roll back
cauemarcondes Sep 21, 2021
920446d
ading more tests
cauemarcondes Sep 21, 2021
fb99e15
fixing observability api
cauemarcondes Sep 21, 2021
d039b26
Merge branch '7.15' of github.com:elastic/kibana into apm-throughput-fix
cauemarcondes Sep 22, 2021
0346169
removing tps
cauemarcondes Sep 22, 2021
c8626e2
fixing ci
cauemarcondes Sep 22, 2021
5461eaa
fixing throughput
cauemarcondes Sep 22, 2021
44fdd99
fixing i18n and test
cauemarcondes Sep 22, 2021
e51dca8
fixing tests
cauemarcondes Sep 23, 2021
a6506ed
addressing pr comments
cauemarcondes Sep 23, 2021
39ea850
fixing ci
cauemarcondes Sep 23, 2021
513961d
Merge branch '7.15' into apm-throughput-fix
kibanamachine Sep 27, 2021
4fb3901
improving tests
cauemarcondes Sep 27, 2021
22f04e3
Merge branch 'apm-throughput-fix' of github.com:cauemarcondes/kibana …
cauemarcondes Sep 27, 2021
63ddf04
adding throughput api test
cauemarcondes Sep 29, 2021
6246a7b
Merge branch '7.15' into apm-throughput-fix
kibanamachine Sep 29, 2021
c014d4c
Merge branch '7.15' of github.com:elastic/kibana into apm-throughput-fix
cauemarcondes Oct 4, 2021
832a6df
adding throughput tests
cauemarcondes Oct 5, 2021
31992c5
Merge branch 'apm-throughput-fix' of github.com:cauemarcondes/kibana …
cauemarcondes Oct 5, 2021
cfd6c20
addressing PR changes
cauemarcondes Oct 5, 2021
a8ea02e
adding dependencies test
cauemarcondes Oct 5, 2021
5ef60ce
adding tests for dependencies apis
cauemarcondes Oct 5, 2021
9489676
addressing pr changes
cauemarcondes Oct 6, 2021
a281db3
renaming archives
cauemarcondes Oct 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions x-pack/plugins/apm/common/utils/formatters/duration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import { i18n } from '@kbn/i18n';
import moment from 'moment';
import { memoize } from 'lodash';
import { NOT_AVAILABLE_LABEL } from '../../../common/i18n';
import { asDecimalOrInteger, asInteger, asDecimal } from './formatters';
import {
asDecimalOrInteger,
asInteger,
asDecimal,
asPreciseDecimal,
} from './formatters';
import { TimeUnit } from './datetime';
import { Maybe } from '../../../typings/common';
import { isFiniteNumber } from '../is_finite_number';
Expand Down Expand Up @@ -185,7 +190,10 @@ export function asTransactionRate(value: Maybe<number>) {
export function asExactTransactionRate(value: number, unit: ThroughputUnit) {
return i18n.translate('xpack.apm.exactTransactionRateLabel', {
defaultMessage: `{value} { unit, select, minute {tpm} other {tps} }`,
values: { value: asDecimalOrInteger(value), unit },
values: {
value: value >= 1 ? asDecimalOrInteger(value) : asPreciseDecimal(value),
unit,
},
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
* 2.0.
*/

import {
SPAN_DESTINATION_SERVICE_RESOURCE,
SPAN_DESTINATION_SERVICE_RESPONSE_TIME_COUNT,
} from '../../../common/elasticsearch_fieldnames';
import { SPAN_DESTINATION_SERVICE_RESOURCE } from '../../../common/elasticsearch_fieldnames';
import { environmentQuery } from '../../../common/utils/environment_query';
import { kqlQuery, rangeQuery } from '../../../../observability/server';
import { ProcessorEvent } from '../../../common/processor_event';
import { Setup } from '../helpers/setup_request';
import { getMetricsDateHistogramParams } from '../helpers/metrics';
import { getOffsetInMs } from '../../../common/utils/get_offset_in_ms';
import { calculateThroughput } from '../helpers/calculate_throughput';

export async function getThroughputChartsForBackend({
backendName,
Expand Down Expand Up @@ -64,14 +62,6 @@ export async function getThroughputChartsForBackend({
end: endWithOffset,
metricsInterval: 60,
}),
aggs: {
throughput: {
rate: {
field: SPAN_DESTINATION_SERVICE_RESPONSE_TIME_COUNT,
unit: 'minute',
},
},
},
},
},
},
Expand All @@ -81,7 +71,7 @@ export async function getThroughputChartsForBackend({
response.aggregations?.timeseries.buckets.map((bucket) => {
return {
x: bucket.key + offsetInMs,
y: bucket.throughput.value,
y: calculateThroughput({ start, end, value: bucket.doc_count }),
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
};
}) ?? []
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,7 @@ export function getConnectionStats({
: null,
timeseries: mergedStats.timeseries.map((point) => ({
x: point.x,
y:
point.count > 0
? calculateThroughput({ start, end, value: point.count })
: null,
y: point.count, // sparklines only shows trend (no axis)
})),
},
errorRate: {
Expand Down
33 changes: 30 additions & 3 deletions x-pack/plugins/apm/server/lib/helpers/calculate_throughput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,40 @@

import { SetupTimeRange } from './setup_request';

function getThroughputValue({
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
durationAsSeconds,
unit,
value,
}: {
durationAsSeconds: number;
unit: ThroughputUnit;
value: number;
}) {
const duration =
unit === 'minute' ? durationAsSeconds / 60 : durationAsSeconds;
return value / duration;
}

export function calculateThroughput({
start,
end,
value,
}: SetupTimeRange & { value: number }) {
const durationAsMinutes = (end - start) / 1000 / 60;
return value / durationAsMinutes;
unit = 'minute',
}: SetupTimeRange & { value: number; unit?: ThroughputUnit }) {
const durationAsSeconds = (end - start) / 1000;
return getThroughputValue({ durationAsSeconds, unit, value });
}

export function calculateThroughputWithInterval({
durationAsSeconds,
value,
unit = 'minute',
}: {
durationAsSeconds: number;
value: number;
unit?: ThroughputUnit;
}) {
return getThroughputValue({ durationAsSeconds, unit, value });
}

export type ThroughputUnit = 'minute' | 'second';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ export async function getTransactionsPerMinute({
fixed_interval: bucketSize,
min_doc_count: 0,
},
aggs: {
throughput: { rate: { unit: 'minute' as const } },
},
},
},
},
Expand Down Expand Up @@ -94,7 +91,7 @@ export async function getTransactionsPerMinute({
timeseries:
topTransactionTypeBucket?.timeseries.buckets.map((bucket) => ({
x: bucket.key,
y: bucket.throughput.value,
y: calculateThroughput({ start, end, value: bucket.doc_count }),
cauemarcondes marked this conversation as resolved.
Show resolved Hide resolved
})) || [],
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { keyBy } from 'lodash';
import { kqlQuery, rangeQuery } from '../../../../observability/server';
import {
EVENT_OUTCOME,
SERVICE_NAME,
Expand All @@ -14,9 +15,8 @@ import {
} from '../../../common/elasticsearch_fieldnames';
import { EventOutcome } from '../../../common/event_outcome';
import { LatencyAggregationType } from '../../../common/latency_aggregation_types';
import { offsetPreviousPeriodCoordinates } from '../../../common/utils/offset_previous_period_coordinate';
import { kqlQuery, rangeQuery } from '../../../../observability/server';
import { environmentQuery } from '../../../common/utils/environment_query';
import { offsetPreviousPeriodCoordinates } from '../../../common/utils/offset_previous_period_coordinate';
import { Coordinate } from '../../../typings/timeseries';
import {
getDocumentTypeFilterForAggregatedTransactions,
Expand Down Expand Up @@ -125,11 +125,6 @@ export async function getServiceTransactionGroupDetailedStatistics({
},
},
aggs: {
throughput_rate: {
rate: {
unit: 'minute',
},
},
...getLatencyAggregation(latencyAggregationType, field),
[EVENT_OUTCOME]: {
terms: {
Expand Down Expand Up @@ -160,7 +155,7 @@ export async function getServiceTransactionGroupDetailedStatistics({
}));
const throughput = bucket.timeseries.buckets.map((timeseriesBucket) => ({
x: timeseriesBucket.key,
y: timeseriesBucket.throughput_rate.value,
y: timeseriesBucket.doc_count, // sparklines only shows trend (no axis)
}));
const errorRate = bucket.timeseries.buckets.map((timeseriesBucket) => ({
x: timeseriesBucket.key,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
getProcessorEventForAggregatedTransactions,
getTransactionDurationFieldForAggregatedTransactions,
} from '../../helpers/aggregated_transactions';
import { calculateThroughput } from '../../helpers/calculate_throughput';
import { getBucketSizeForAggregatedTransactions } from '../../helpers/get_bucket_size_for_aggregated_transactions';
import { Setup, SetupTimeRange } from '../../helpers/setup_request';
import {
Expand Down Expand Up @@ -154,11 +153,7 @@ export async function getServiceTransactionDetailedStatistics({
throughput: topTransactionTypeBucket.timeseries.buckets.map(
(dateBucket) => ({
x: dateBucket.key + offsetInMs,
y: calculateThroughput({
start,
end,
value: dateBucket.doc_count,
}),
y: dateBucket.doc_count, // sparklines only shows trend (no axis)
})
),
};
Expand Down
21 changes: 12 additions & 9 deletions x-pack/plugins/apm/server/lib/services/get_throughput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import {
getProcessorEventForAggregatedTransactions,
} from '../helpers/aggregated_transactions';
import { Setup } from '../helpers/setup_request';
import {
calculateThroughputWithInterval,
ThroughputUnit,
} from '../helpers/calculate_throughput';

interface Options {
environment: string;
Expand All @@ -28,7 +32,8 @@ interface Options {
start: number;
end: number;
intervalString: string;
throughputUnit: 'minute' | 'second';
bucketSize: number;
throughputUnit: ThroughputUnit;
}

export async function getThroughput({
Expand All @@ -41,6 +46,7 @@ export async function getThroughput({
start,
end,
intervalString,
bucketSize,
throughputUnit,
}: Options) {
const { apmEventClient } = setup;
Expand Down Expand Up @@ -75,13 +81,6 @@ export async function getThroughput({
min_doc_count: 0,
extended_bounds: { min: start, max: end },
},
aggs: {
throughput: {
rate: {
unit: throughputUnit,
},
},
},
},
},
},
Expand All @@ -96,7 +95,11 @@ export async function getThroughput({
response.aggregations?.timeseries.buckets.map((bucket) => {
return {
x: bucket.key,
y: bucket.throughput.value,
y: calculateThroughputWithInterval({
durationAsSeconds: bucketSize,
value: bucket.doc_count,
unit: throughputUnit,
}),
};
}) ?? []
);
Expand Down
7 changes: 4 additions & 3 deletions x-pack/plugins/apm/server/routes/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { uniq } from 'lodash';
import { latencyAggregationTypeRt } from '../../common/latency_aggregation_types';
import { ProfilingValueType } from '../../common/profiling';
import { getSearchAggregatedTransactions } from '../lib/helpers/aggregated_transactions';
import { getThroughputUnit } from '../lib/helpers/calculate_throughput';
import { setupRequest } from '../lib/helpers/setup_request';
import { getServiceAnnotations } from '../lib/services/annotations';
import { getServices } from '../lib/services/get_services';
Expand Down Expand Up @@ -46,6 +45,7 @@ import { offsetPreviousPeriodCoordinates } from '../../common/utils/offset_previ
import { getServicesDetailedStatistics } from '../lib/services/get_services_detailed_statistics';
import { getServiceDependenciesBreakdown } from '../lib/services/get_service_dependencies_breakdown';
import { getBucketSizeForAggregatedTransactions } from '../lib/helpers/get_bucket_size_for_aggregated_transactions';
import { getThroughputUnit } from '../lib/helpers/calculate_throughput';

const servicesRoute = createApmServerRoute({
endpoint: 'GET /api/apm/services',
Expand Down Expand Up @@ -476,8 +476,8 @@ const serviceThroughputRoute = createApmServerRoute({

const { start, end } = setup;
const {
bucketSize,
intervalString,
bucketSize,
} = getBucketSizeForAggregatedTransactions({
start,
end,
Expand All @@ -493,8 +493,9 @@ const serviceThroughputRoute = createApmServerRoute({
serviceName,
setup,
transactionType,
throughputUnit,
intervalString,
bucketSize,
throughputUnit,
};

const [currentPeriod, previousPeriod] = await Promise.all([
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -7081,9 +7081,6 @@
"xpack.apm.serviceOverview.mlNudgeMessage.learnMoreButton": "使ってみる",
"xpack.apm.serviceOverview.throughtputChart.previousPeriodLabel": "前の期間",
"xpack.apm.serviceOverview.throughtputChartTitle": "スループット",
"xpack.apm.serviceOverview.throughtputPerSecondChartTitle": " (秒単位)",
"xpack.apm.serviceOverview.tpmHelp": "スループットは1分あたりのトランザクション数(tpm)で測定されます",
"xpack.apm.serviceOverview.tpsHelp": "スループットは1秒あたりのトランザクション数(tps)で測定されます",
"xpack.apm.serviceOverview.transactionsTableColumnErrorRate": "失敗したトランザクション率",
"xpack.apm.serviceOverview.transactionsTableColumnImpact": "インパクト",
"xpack.apm.serviceOverview.transactionsTableColumnName": "名前",
Expand Down
3 changes: 0 additions & 3 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -7136,9 +7136,6 @@
"xpack.apm.serviceOverview.mlNudgeMessage.learnMoreButton": "开始使用",
"xpack.apm.serviceOverview.throughtputChart.previousPeriodLabel": "上一时段",
"xpack.apm.serviceOverview.throughtputChartTitle": "吞吐量",
"xpack.apm.serviceOverview.throughtputPerSecondChartTitle": " (每秒)",
"xpack.apm.serviceOverview.tpmHelp": "吞吐量按每分钟事务数 (tpm) 来度量",
"xpack.apm.serviceOverview.tpsHelp": "吞吐量按每秒事务数 (tps) 来度量",
"xpack.apm.serviceOverview.transactionsTableColumnErrorRate": "失败事务率",
"xpack.apm.serviceOverview.transactionsTableColumnImpact": "影响",
"xpack.apm.serviceOverview.transactionsTableColumnName": "名称",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,23 @@ export default function ApiTest({ getService }: FtrProviderContext) {
Array [
Object {
"x": "2021-08-03T06:50:00.000Z",
"y": 51,
"y": 1.7,
},
Object {
"x": "2021-08-03T06:51:00.000Z",
"y": 62,
"y": 2.06666666666667,
},
Object {
"x": "2021-08-03T06:52:00.000Z",
"y": 56,
"y": 1.86666666666667,
},
Object {
"x": "2021-08-03T06:53:00.000Z",
"y": 50,
"y": 1.66666666666667,
},
Object {
"x": "2021-08-03T06:54:00.000Z",
"y": 77,
"y": 2.56666666666667,
},
]
`);
Expand Down
Loading