Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/polite-grapes-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@hyperdx/common-utils": patch
"@hyperdx/api": patch
"@hyperdx/app": patch
"@hyperdx/cli": patch
---

feat: Add additional alert threshold types
6 changes: 5 additions & 1 deletion packages/api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@
"type": "string",
"enum": [
"above",
"below"
"below",
"above_exclusive",
"below_or_equal",
"equal",
"not_equal"
],
"description": "Threshold comparison direction."
},
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/controllers/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
validateRawSqlForAlert,
} from '@hyperdx/common-utils/dist/core/utils';
import { isRawSqlSavedChartConfig } from '@hyperdx/common-utils/dist/guards';
import { AlertThresholdType } from '@hyperdx/common-utils/dist/types';
import { sign, verify } from 'jsonwebtoken';
import { groupBy } from 'lodash';
import ms from 'ms';
Expand All @@ -13,7 +14,6 @@ import Alert, {
AlertChannel,
AlertInterval,
AlertSource,
AlertThresholdType,
IAlert,
} from '@/models/alert';
import Dashboard, { IDashboard } from '@/models/dashboard';
Expand Down
3 changes: 2 additions & 1 deletion packages/api/src/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createNativeClient } from '@hyperdx/common-utils/dist/clickhouse/node';
import {
AlertThresholdType,
BuilderSavedChartConfig,
DisplayType,
RawSqlSavedChartConfig,
Expand All @@ -15,7 +16,7 @@ import { AlertInput } from '@/controllers/alerts';
import { getTeam } from '@/controllers/team';
import { findUserByEmail } from '@/controllers/user';
import { mongooseConnection } from '@/models';
import { AlertInterval, AlertSource, AlertThresholdType } from '@/models/alert';
import { AlertInterval, AlertSource } from '@/models/alert';
import Server from '@/server';
import logger from '@/utils/logger';
import { MetricModel } from '@/utils/logParser';
Expand Down
11 changes: 5 additions & 6 deletions packages/api/src/models/alert.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { ALERT_INTERVAL_TO_MINUTES } from '@hyperdx/common-utils/dist/types';
import {
ALERT_INTERVAL_TO_MINUTES,
AlertThresholdType,
} from '@hyperdx/common-utils/dist/types';
export { AlertThresholdType } from '@hyperdx/common-utils/dist/types';
import mongoose, { Schema } from 'mongoose';

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

export enum AlertThresholdType {
ABOVE = 'above',
BELOW = 'below',
}

export enum AlertState {
ALERT = 'ALERT',
DISABLED = 'DISABLED',
Expand Down
7 changes: 5 additions & 2 deletions packages/api/src/routers/api/__tests__/alerts.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { DisplayType } from '@hyperdx/common-utils/dist/types';
import {
AlertThresholdType,
DisplayType,
} from '@hyperdx/common-utils/dist/types';

import {
getLoggedInAgent,
Expand All @@ -11,7 +14,7 @@ import {
randomMongoId,
RAW_SQL_ALERT_TEMPLATE,
} from '@/fixtures';
import Alert, { AlertSource, AlertThresholdType } from '@/models/alert';
import Alert, { AlertSource } from '@/models/alert';
import Webhook, { WebhookDocument, WebhookService } from '@/models/webhook';

const MOCK_TILES = [makeTile(), makeTile(), makeTile(), makeTile(), makeTile()];
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/routers/external-api/v2/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { alertSchema, objectIdSchema } from '@/utils/zod';
* description: Evaluation interval.
* AlertThresholdType:
* type: string
* enum: [above, below]
* enum: [above, below, above_exclusive, below_or_equal, equal, not_equal]
* description: Threshold comparison direction.
* AlertSource:
* type: string
Expand Down
Loading
Loading