Skip to content

Commit 973076d

Browse files
committed
fix(anomaly detection): filter out overlap between historical data and current data
1 parent e7e09bb commit 973076d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

static/app/views/alerts/rules/metric/ruleForm.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,12 @@ class RuleFormContainer extends DeprecatedAsyncComponent<Props, State> {
10761076
: thresholdType === AlertRuleThresholdType.BELOW
10771077
? 'down'
10781078
: 'both';
1079+
1080+
// extract the earliest timestamp from the current dataset
1081+
const startOfCurrentTimeframe = currentData.reduce(
1082+
(value, [timestamp]) => (value < timestamp ? value : timestamp),
1083+
Infinity
1084+
);
10791085
const params = {
10801086
organization_id: organization.id,
10811087
project_id: project.id,
@@ -1085,7 +1091,10 @@ class RuleFormContainer extends DeprecatedAsyncComponent<Props, State> {
10851091
direction,
10861092
expected_seasonality: seasonality,
10871093
},
1088-
historical_data: historicalData,
1094+
// remove historical data that overlaps with current dataset
1095+
historical_data: historicalData.filter(
1096+
([timestamp]) => timestamp < startOfCurrentTimeframe
1097+
),
10891098
current_data: currentData,
10901099
};
10911100

0 commit comments

Comments
 (0)