Skip to content

Commit c0dd8c9

Browse files
committed
feat: Add additional alert threshold types
1 parent 4ca1d47 commit c0dd8c9

18 files changed

Lines changed: 1259 additions & 77 deletions

File tree

.changeset/polite-grapes-cross.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@hyperdx/common-utils": patch
3+
"@hyperdx/api": patch
4+
"@hyperdx/app": patch
5+
"@hyperdx/cli": patch
6+
---
7+
8+
feat: Add additional alert threshold types

packages/api/openapi.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@
7070
"type": "string",
7171
"enum": [
7272
"above",
73-
"below"
73+
"below",
74+
"above_exclusive",
75+
"below_or_equal",
76+
"equal",
77+
"not_equal"
7478
],
7579
"description": "Threshold comparison direction."
7680
},

packages/api/src/controllers/alerts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
validateRawSqlForAlert,
44
} from '@hyperdx/common-utils/dist/core/utils';
55
import { isRawSqlSavedChartConfig } from '@hyperdx/common-utils/dist/guards';
6+
import { AlertThresholdType } from '@hyperdx/common-utils/dist/types';
67
import { sign, verify } from 'jsonwebtoken';
78
import { groupBy } from 'lodash';
89
import ms from 'ms';
@@ -13,7 +14,6 @@ import Alert, {
1314
AlertChannel,
1415
AlertInterval,
1516
AlertSource,
16-
AlertThresholdType,
1717
IAlert,
1818
} from '@/models/alert';
1919
import Dashboard, { IDashboard } from '@/models/dashboard';

packages/api/src/fixtures.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { createNativeClient } from '@hyperdx/common-utils/dist/clickhouse/node';
22
import {
3+
AlertThresholdType,
34
BuilderSavedChartConfig,
45
DisplayType,
56
RawSqlSavedChartConfig,
@@ -15,7 +16,7 @@ import { AlertInput } from '@/controllers/alerts';
1516
import { getTeam } from '@/controllers/team';
1617
import { findUserByEmail } from '@/controllers/user';
1718
import { mongooseConnection } from '@/models';
18-
import { AlertInterval, AlertSource, AlertThresholdType } from '@/models/alert';
19+
import { AlertInterval, AlertSource } from '@/models/alert';
1920
import Server from '@/server';
2021
import logger from '@/utils/logger';
2122
import { MetricModel } from '@/utils/logParser';

packages/api/src/models/alert.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
import { ALERT_INTERVAL_TO_MINUTES } from '@hyperdx/common-utils/dist/types';
1+
import {
2+
ALERT_INTERVAL_TO_MINUTES,
3+
AlertThresholdType,
4+
} from '@hyperdx/common-utils/dist/types';
5+
export { AlertThresholdType } from '@hyperdx/common-utils/dist/types';
26
import mongoose, { Schema } from 'mongoose';
37

48
import type { ObjectId } from '.';
59
import Team from './team';
610

7-
export enum AlertThresholdType {
8-
ABOVE = 'above',
9-
BELOW = 'below',
10-
}
11-
1211
export enum AlertState {
1312
ALERT = 'ALERT',
1413
DISABLED = 'DISABLED',

packages/api/src/routers/api/__tests__/alerts.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
import { DisplayType } from '@hyperdx/common-utils/dist/types';
1+
import {
2+
AlertThresholdType,
3+
DisplayType,
4+
} from '@hyperdx/common-utils/dist/types';
25

36
import {
47
getLoggedInAgent,
@@ -11,7 +14,7 @@ import {
1114
randomMongoId,
1215
RAW_SQL_ALERT_TEMPLATE,
1316
} from '@/fixtures';
14-
import Alert, { AlertSource, AlertThresholdType } from '@/models/alert';
17+
import Alert, { AlertSource } from '@/models/alert';
1518
import Webhook, { WebhookDocument, WebhookService } from '@/models/webhook';
1619

1720
const MOCK_TILES = [makeTile(), makeTile(), makeTile(), makeTile(), makeTile()];

packages/api/src/routers/external-api/v2/alerts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { alertSchema, objectIdSchema } from '@/utils/zod';
3434
* description: Evaluation interval.
3535
* AlertThresholdType:
3636
* type: string
37-
* enum: [above, below]
37+
* enum: [above, below, above_exclusive, below_or_equal, equal, not_equal]
3838
* description: Threshold comparison direction.
3939
* AlertSource:
4040
* type: string

0 commit comments

Comments
 (0)