[APM] Latency threshold alerts are not being triggered (#110315)
This commit is contained in:
parent
6d7998e70c
commit
49e3edf032
|
@ -5,9 +5,8 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/api/types';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import type {
|
||||
ALERT_EVALUATION_THRESHOLD as ALERT_EVALUATION_THRESHOLD_TYPED,
|
||||
ALERT_EVALUATION_VALUE as ALERT_EVALUATION_VALUE_TYPED,
|
||||
|
@ -19,33 +18,36 @@ import {
|
|||
ALERT_REASON as ALERT_REASON_NON_TYPED,
|
||||
// @ts-expect-error
|
||||
} from '@kbn/rule-data-utils/target_node/technical_field_names';
|
||||
import { SearchAggregatedTransactionSetting } from '../../../common/aggregated_transactions';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { asDuration } from '../../../../observability/common/utils/formatters';
|
||||
import { createLifecycleRuleTypeFactory } from '../../../../rule_registry/server';
|
||||
import {
|
||||
getEnvironmentLabel,
|
||||
getEnvironmentEsField,
|
||||
} from '../../../common/environment_filter_values';
|
||||
import { SearchAggregatedTransactionSetting } from '../../../common/aggregated_transactions';
|
||||
import {
|
||||
AlertType,
|
||||
APM_SERVER_FEATURE_ID,
|
||||
ALERT_TYPES_CONFIG,
|
||||
APM_SERVER_FEATURE_ID,
|
||||
formatTransactionDurationReason,
|
||||
} from '../../../common/alert_types';
|
||||
import {
|
||||
PROCESSOR_EVENT,
|
||||
SERVICE_NAME,
|
||||
TRANSACTION_DURATION,
|
||||
TRANSACTION_TYPE,
|
||||
} from '../../../common/elasticsearch_fieldnames';
|
||||
import {
|
||||
getEnvironmentEsField,
|
||||
getEnvironmentLabel,
|
||||
} from '../../../common/environment_filter_values';
|
||||
import { ProcessorEvent } from '../../../common/processor_event';
|
||||
import { getDurationFormatter } from '../../../common/utils/formatters';
|
||||
import { environmentQuery } from '../../../common/utils/environment_query';
|
||||
import { getDurationFormatter } from '../../../common/utils/formatters';
|
||||
import {
|
||||
getDocumentTypeFilterForAggregatedTransactions,
|
||||
getTransactionDurationFieldForAggregatedTransactions,
|
||||
} from '../helpers/aggregated_transactions';
|
||||
import { getApmIndices } from '../settings/apm_indices/get_apm_indices';
|
||||
import { apmActionVariables } from './action_variables';
|
||||
import { alertingEsClient } from './alerting_es_client';
|
||||
import { RegisterRuleDependencies } from './register_apm_alerts';
|
||||
import { getDocumentTypeFilterForAggregatedTransactions } from '../helpers/aggregated_transactions';
|
||||
|
||||
const ALERT_EVALUATION_THRESHOLD: typeof ALERT_EVALUATION_THRESHOLD_TYPED = ALERT_EVALUATION_THRESHOLD_NON_TYPED;
|
||||
const ALERT_EVALUATION_VALUE: typeof ALERT_EVALUATION_VALUE_TYPED = ALERT_EVALUATION_VALUE_NON_TYPED;
|
||||
|
@ -118,6 +120,10 @@ export function registerTransactionDurationAlertType({
|
|||
? indices['apm_oss.metricsIndices']
|
||||
: indices['apm_oss.transactionIndices'];
|
||||
|
||||
const field = getTransactionDurationFieldForAggregatedTransactions(
|
||||
searchAggregatedTransactions
|
||||
);
|
||||
|
||||
const searchParams = {
|
||||
index,
|
||||
body: {
|
||||
|
@ -148,10 +154,10 @@ export function registerTransactionDurationAlertType({
|
|||
aggs: {
|
||||
latency:
|
||||
alertParams.aggregationType === 'avg'
|
||||
? { avg: { field: TRANSACTION_DURATION } }
|
||||
? { avg: { field } }
|
||||
: {
|
||||
percentiles: {
|
||||
field: TRANSACTION_DURATION,
|
||||
field,
|
||||
percents: [
|
||||
alertParams.aggregationType === '95th' ? 95 : 99,
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue