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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
import moment from 'moment';
import React, { useEffect, useMemo } from 'react';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { toMicroseconds as toMicrosecondsUtil } from '../../../../../common/utils/formatters';
import { SERVICE_ENVIRONMENT } from '../../../../../common/es_fields/apm';
import { ChartPointerEventContextProvider } from '../../../../context/chart_pointer_event/chart_pointer_event_context';
import { TimeRangeMetadataContextProvider } from '../../../../context/time_range_metadata/time_range_metadata_context';
Expand All @@ -36,9 +35,6 @@ import {
TRANSACTION_TYPE,
} from './types';

const toMicroseconds = (value?: number) =>
value ? toMicrosecondsUtil(value, 'milliseconds') : value;

export function AlertDetailsAppSection({
rule,
alert,
Expand Down Expand Up @@ -68,7 +64,7 @@ export function AlertDetailsAppSection({
),
value: formatAlertEvaluationValue(
alert?.fields[ALERT_RULE_TYPE_ID],
toMicroseconds(alert?.fields[ALERT_EVALUATION_THRESHOLD])
alert?.fields[ALERT_EVALUATION_THRESHOLD]
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ export function registerTransactionDurationRuleType({
[TRANSACTION_NAME]: ruleParams.transactionName,
[PROCESSOR_EVENT]: ProcessorEvent.transaction,
[ALERT_EVALUATION_VALUE]: transactionDuration,
[ALERT_EVALUATION_THRESHOLD]: ruleParams.threshold,
[ALERT_EVALUATION_THRESHOLD]: thresholdMicroseconds,
[ALERT_REASON]: reason,
...sourceFields,
...groupByFields,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { AlertLifecycleStatusBadge } from '@kbn/alerts-ui-shared';
import moment from 'moment-timezone';
import { useUiSetting } from '@kbn/kibana-react-plugin/public';
import { useKibana } from '../utils/kibana_react';
import { asDuration, toMicroseconds } from '../../common/utils/formatters';
import { asDuration } from '../../common/utils/formatters';
import { paths } from '../config/paths';
import { translations } from '../config/translations';
import { formatAlertEvaluationValue } from '../utils/format_alert_evaluation_value';
Expand All @@ -42,14 +42,6 @@ interface FlyoutProps {
id?: string;
}

// For APM Latency threshold rule, threshold is in ms but the duration formatter works with microseconds
const normalizeUnit = (ruleTypeId: string, value?: number) => {
if (ruleTypeId === 'apm.transaction_duration' && value) {
return toMicroseconds(value, 'milliseconds');
}
return value;
};

export function AlertsFlyoutBody({ alert, id: pageId }: FlyoutProps) {
const {
http: {
Expand Down Expand Up @@ -97,7 +89,7 @@ export function AlertsFlyoutBody({ alert, id: pageId }: FlyoutProps) {
title: translations.alertsFlyout.expectedValueLabel,
description: formatAlertEvaluationValue(
alert.fields[ALERT_RULE_TYPE_ID],
normalizeUnit(alert.fields[ALERT_RULE_TYPE_ID], alert.fields[ALERT_EVALUATION_THRESHOLD])
alert.fields[ALERT_EVALUATION_THRESHOLD]
),
},
{
Expand Down