Skip to content

Commit f612bf3

Browse files
authored
feat: add support for alert auto-resolve + Incident.io integration (#1298)
Plus fixed 'group-by' alert state issues (alert histories) <img width="836" height="362" alt="image" src="https://github.com/user-attachments/assets/1c132313-25ea-4059-9b7c-0bfaa85408ea" /> Ref: HDX-2661 Ref: HDX-2660
1 parent 8dee21c commit f612bf3

File tree

17 files changed

+2340
-355
lines changed

17 files changed

+2340
-355
lines changed

.changeset/brave-meals-judge.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@hyperdx/common-utils": minor
3+
"@hyperdx/api": minor
4+
"@hyperdx/app": minor
5+
---
6+
7+
feat: add support for alert auto-resolve
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@hyperdx/common-utils": patch
3+
"@hyperdx/api": patch
4+
"@hyperdx/app": patch
5+
---
6+
7+
feat: support incident.io integration

.changeset/good-feet-jog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@hyperdx/common-utils": patch
3+
"@hyperdx/api": patch
4+
"@hyperdx/app": patch
5+
---
6+
7+
fix: handle group-by alert histories

packages/api/src/controllers/alerts.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import logger from '@/utils/logger';
1818
import { alertSchema } from '@/utils/zod';
1919

2020
export type AlertInput = {
21+
id?: string;
2122
source?: AlertSource;
2223
channel: AlertChannel;
2324
interval: AlertInterval;

packages/api/src/models/alertHistory.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface IAlertHistory {
1111
createdAt: Date;
1212
state: AlertState;
1313
lastValues: { startTime: Date; count: number }[];
14+
group?: string; // For group-by alerts, stores the group identifier
1415
}
1516

1617
const AlertHistorySchema = new Schema<IAlertHistory>({
@@ -40,13 +41,20 @@ const AlertHistorySchema = new Schema<IAlertHistory>({
4041
},
4142
},
4243
],
44+
group: {
45+
type: String,
46+
required: false,
47+
},
4348
});
4449

4550
AlertHistorySchema.index(
4651
{ createdAt: 1 },
4752
{ expireAfterSeconds: ms('30d') / 1000 },
4853
);
4954

55+
// Compound index for querying alert histories by alert and time
56+
// Used by getPreviousAlertHistories and alerts router
57+
// Supports queries like: { alert: id, createdAt: { $lte: date } } with sort { createdAt: -1 }
5058
AlertHistorySchema.index({ alert: 1, createdAt: -1 });
5159

5260
export default mongoose.model<IAlertHistory>(

packages/api/src/models/webhook.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1+
import { WebhookService } from '@hyperdx/common-utils/dist/types';
12
import { ObjectId } from 'mongodb';
23
import mongoose, { Schema } from 'mongoose';
34

4-
export enum WebhookService {
5-
Slack = 'slack',
6-
Generic = 'generic',
7-
}
5+
export { WebhookService };
86

97
interface MongooseMap extends Map<string, string> {
108
// https://mongoosejs.com/docs/api/map.html#MongooseMap.prototype.toJSON()

0 commit comments

Comments
 (0)