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 @@ -21,7 +21,6 @@ import React, { useEffect, useMemo } from 'react';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { getPaddedAlertTimeRange } from '@kbn/observability-alert-details';
import { EuiCallOut } from '@elastic/eui';
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 @@ -37,9 +36,6 @@ import {
TRANSACTION_TYPE,
} from './types';

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

export function AlertDetailsAppSection({
rule,
alert,
Expand Down Expand Up @@ -69,7 +65,7 @@ export function AlertDetailsAppSection({
),
value: formatAlertEvaluationValue(
alert?.fields[ALERT_RULE_TYPE_ID],
toMicroseconds(alert?.fields[ALERT_EVALUATION_THRESHOLD])
alert?.fields[ALERT_EVALUATION_THRESHOLD]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like alert?.fields[ALERT_EVALUATION_THRESHOLD] was previously in milliseconds but going forward it will be in microseconds? Where does this happen?

@maryam-saeidi maryam-saeidi Jun 1, 2023 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the change: (next file change in this PR)

[ALERT_EVALUATION_THRESHOLD]: thresholdMicroseconds,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. lgtm 👍

),
},
{
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