Skip to content

Commit f49d2c5

Browse files
Merge pull request #550 from Fewwy/OU-1011
OU-1011: add a 5 minute to the first alert timestamp
2 parents 4b012b3 + a2cd9d8 commit f49d2c5

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

web/src/components/Incidents/processAlerts.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,16 @@ export function processAlerts(
166166
}
167167
const matchingRule = alertingRules.find((rule) => rule.name === alert.metric.alertname);
168168

169-
const alertsStartFiring = sortedValues[0][0] * 1000;
169+
// Create a new timestamp 5 minutes (300 seconds) earlier than the first timestamp
170+
const originalAlertsStartFiring = sortedValues[0][0] * 1000;
171+
const newFirstTimestamp = sortedValues[0][0] - 5 * 60;
172+
173+
// Create a copy of the first value from the array of timestamps and update its timestamp
174+
const newFirstValue: [number, string] = [newFirstTimestamp, sortedValues[0][1]];
175+
// Unshift the new value to the beginning of the sortedValues array
176+
sortedValues.unshift(newFirstValue);
177+
178+
const alertsStartFiring = originalAlertsStartFiring - 5 * 60 * 1000;
170179
const alertsEndFiring = sortedValues[sortedValues.length - 1][0] * 1000;
171180
const resolved = Date.now() - alertsEndFiring > 10 * 60 * 1000;
172181

0 commit comments

Comments
 (0)