Skip to content

Commit

Permalink
fix(anomaly detection): restore correct alert reasons for anomaly det…
Browse files Browse the repository at this point in the history
…ection alerts (#84400)

The code to display anomaly detection alert trigger reasons was removed
during a refactor. Restore the code that displays the correct reason.
Note: the original code that generates reasons for anomaly detection
alerts was introduced in #77331.

Before:
![Screenshot 2025-01-31 at 3 36
38 PM](https://github.com/user-attachments/assets/0887d5fb-a088-4f0a-83aa-3436ff013608)

After:
![Screenshot 2025-01-31 at 3 36
30 PM](https://github.com/user-attachments/assets/9b2a6c16-e2f6-4a4b-8865-d803ca5bdcba)
  • Loading branch information
mifu67 authored Feb 1, 2025
1 parent b1f749f commit d210118
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions static/app/views/alerts/rules/metric/details/metricHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,39 @@ function MetricAlertActivity({organization, incident}: MetricAlertActivityProps)
</Link>
</Cell>
<Cell>
{incident.alertRule.comparisonDelta ? (
{/* If an alert rule is a % comparison based detection type */}
{incident.alertRule.detectionType !== 'dynamic' &&
incident.alertRule.comparisonDelta && (
<Fragment>
{alertName} {curentTrigger?.alertThreshold}%
{t(
' %s in %s compared to the ',
incident.alertRule.thresholdType === AlertRuleThresholdType.ABOVE
? t('higher')
: t('lower'),
timeWindow
)}
{COMPARISON_DELTA_OPTIONS.find(
({value}) => value === incident.alertRule.comparisonDelta
)?.label ?? COMPARISON_DELTA_OPTIONS[0]?.label}
</Fragment>
)}
{/* If an alert rule is a static detection type */}
{incident.alertRule.detectionType !== 'dynamic' &&
!incident.alertRule.comparisonDelta && (
<Fragment>
{alertName}{' '}
{incident.alertRule.thresholdType === AlertRuleThresholdType.ABOVE
? t('above')
: t('below')}{' '}
{curentTrigger?.alertThreshold} {t('in')} {timeWindow}
</Fragment>
)}
{/* If an alert rule is a dynamic detection type */}
{incident.alertRule.detectionType === 'dynamic' && (
<Fragment>
{alertName} {curentTrigger?.alertThreshold}%
{t(
' %s in %s compared to the ',
incident.alertRule.thresholdType === AlertRuleThresholdType.ABOVE
? t('higher')
: t('lower'),
timeWindow
)}
{COMPARISON_DELTA_OPTIONS.find(
({value}) => value === incident.alertRule.comparisonDelta
)?.label ?? COMPARISON_DELTA_OPTIONS[0]?.label}
</Fragment>
) : (
<Fragment>
{alertName}{' '}
{incident.alertRule.thresholdType === AlertRuleThresholdType.ABOVE
? t('above')
: t('below')}{' '}
{curentTrigger?.alertThreshold} {t('in')} {timeWindow}
{t('Detected an anomaly in the query for ')}
{alertName}
</Fragment>
)}
</Cell>
Expand Down

0 comments on commit d210118

Please sign in to comment.