Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion x-pack/solutions/observability/plugins/apm/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ dependsOn:
- '@kbn/react-query'
- '@kbn/core-chrome-layout-constants'
- '@kbn/control-group-renderer'
- '@kbn/zod'
- '@kbn/agent-builder-plugin'
- '@kbn/observability-agent-builder-plugin'
tags:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

import type { CoreSetup, Logger } from '@kbn/core/server';
import { getRollupIntervalForTimeRange } from '@kbn/apm-data-access-plugin/server/utils';
import { getErrorSampleDetails } from '../../routes/errors/get_error_groups/get_error_sample_details';
import { parseDatemath } from '../utils/time';
import { getRollupIntervalForTimeRange } from '../utils/get_rollup_interval_for_time_range';
import { getApmServiceSummary } from '../../routes/assistant_functions/get_apm_service_summary';
import { getApmDownstreamDependencies } from '../../routes/assistant_functions/get_apm_downstream_dependencies';
import { getServicesItems } from '../../routes/services/get_services/get_services_items';
Expand All @@ -19,7 +19,6 @@ import {
getExitSpanChangePoints,
getServiceChangePoints,
} from '../../routes/assistant_functions/get_changepoints';
import { getTraceMetrics } from '../tools/get_trace_metrics';
import { buildApmToolResources } from '../utils/build_apm_tool_resources';
import type { APMPluginSetupDependencies, APMPluginStartDependencies } from '../../types';

Expand Down Expand Up @@ -184,28 +183,4 @@ export function registerDataProviders({
});
}
);

observabilityAgentBuilder.registerDataProvider(
'traceMetrics',
async ({ request, start, end, kqlFilter, groupBy }) => {
const { apmEventClient, apmDataAccessServices } = await buildApmToolResources({
core,
plugins,
request,
logger,
});

const startMs = parseDatemath(start);
const endMs = parseDatemath(end);

return getTraceMetrics({
apmEventClient,
apmDataAccessServices,
start: startMs,
end: endMs,
kqlFilter,
groupBy,
});
}
);
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import { merge } from 'lodash';
import { calculateThroughputWithRange } from '@kbn/apm-data-access-plugin/server/utils';
import type { ValuesType } from 'utility-types';
import { joinByKey } from '../../../../common/utils/join_by_key';
import { withApmSpan } from '../../../utils/with_apm_span';
import { calculateThroughputWithRange } from '../../helpers/calculate_throughput';
import type { APMEventClient } from '../../helpers/create_es_client/create_apm_event_client';
import type { RandomSampler } from '../../helpers/get_random_sampler';
import { getDestinationMap } from './get_destination_map';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,92 +5,11 @@
* 2.0.
*/

import type {
AggregationsSumAggregation,
AggregationsValueCountAggregation,
QueryDslQueryContainer,
} from '@elastic/elasticsearch/lib/api/types';
import type {
AggregationOptionsByType,
AggregationResultOf,
AggregationResultOfMap,
} from '@kbn/es-types';
import { ApmDocumentType } from '../../../common/document_type';
import { EVENT_OUTCOME, EVENT_SUCCESS_COUNT } from '../../../common/es_fields/apm';
import { EventOutcome } from '../../../common/event_outcome';

export const getOutcomeAggregation = (
documentType: ApmDocumentType
): {
successful_or_failed:
| { value_count: AggregationsValueCountAggregation }
| { filter: QueryDslQueryContainer };
successful: { sum: AggregationsSumAggregation } | { filter: QueryDslQueryContainer };
} => {
if (documentType === ApmDocumentType.ServiceTransactionMetric) {
return {
successful_or_failed: {
value_count: {
field: EVENT_SUCCESS_COUNT,
},
},
successful: {
sum: {
field: EVENT_SUCCESS_COUNT,
},
},
};
}

return {
successful_or_failed: {
filter: {
bool: {
filter: [
{
terms: {
[EVENT_OUTCOME]: [EventOutcome.failure, EventOutcome.success],
},
},
],
},
},
},
successful: {
filter: {
bool: {
filter: [
{
terms: {
[EVENT_OUTCOME]: [EventOutcome.success],
},
},
],
},
},
},
};
};

type OutcomeAggregation = ReturnType<typeof getOutcomeAggregation>;

export function calculateFailedTransactionRate(
outcomeResponse: AggregationResultOfMap<OutcomeAggregation, {}>
) {
const successfulTransactions =
'value' in outcomeResponse.successful
? outcomeResponse.successful.value ?? 0
: outcomeResponse.successful.doc_count;

const successfulOrFailedTransactions =
'value' in outcomeResponse.successful_or_failed
? outcomeResponse.successful_or_failed.value
: outcomeResponse.successful_or_failed.doc_count;

const failedTransactions = successfulOrFailedTransactions - successfulTransactions;

return failedTransactions / successfulOrFailedTransactions;
}
import type { AggregationOptionsByType, AggregationResultOf } from '@kbn/es-types';
import {
calculateFailedTransactionRate,
type OutcomeAggregation,
} from '@kbn/apm-data-access-plugin/server/utils';

export function getFailedTransactionRateTimeSeries(
buckets: AggregationResultOf<
Expand Down
Loading