fix(ui/alerts): align RouteMetric metric enum with backend; pre-populate ROUTE_METRIC defaults
- RouteMetricForm dropped P95_LATENCY_MS — not in cameleer-server-core RouteMetric enum (valid: ERROR_RATE, P99_LATENCY_MS, AVG_DURATION_MS, THROUGHPUT, ERROR_COUNT). - initialForm now returns a ready-to-save ROUTE_METRIC condition (metric=ERROR_RATE, comparator=GT, threshold=0.05, windowSeconds=300), so clicking through the wizard with all defaults produces a valid rule. Prevents a 400 'missing type id property kind' + 400 on condition enum validation if the user leaves the condition step untouched.
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import { FormField, Input, Select } from '@cameleer/design-system';
|
import { FormField, Input, Select } from '@cameleer/design-system';
|
||||||
import type { FormState } from '../form-state';
|
import type { FormState } from '../form-state';
|
||||||
|
|
||||||
|
// Mirrors cameleer-server-core RouteMetric enum — keep in sync.
|
||||||
const METRICS = [
|
const METRICS = [
|
||||||
{ value: 'ERROR_RATE', label: 'Error rate' },
|
{ value: 'ERROR_RATE', label: 'Error rate' },
|
||||||
{ value: 'P95_LATENCY_MS', label: 'P95 latency (ms)' },
|
|
||||||
{ value: 'P99_LATENCY_MS', label: 'P99 latency (ms)' },
|
{ value: 'P99_LATENCY_MS', label: 'P99 latency (ms)' },
|
||||||
{ value: 'AVG_DURATION_MS', label: 'Avg duration (ms)' },
|
{ value: 'AVG_DURATION_MS', label: 'Avg duration (ms)' },
|
||||||
{ value: 'THROUGHPUT', label: 'Throughput (msg/s)' },
|
{ value: 'THROUGHPUT', label: 'Throughput (msg/s)' },
|
||||||
|
|||||||
@@ -51,7 +51,17 @@ export function initialForm(existing?: AlertRuleResponse): FormState {
|
|||||||
routeId: '',
|
routeId: '',
|
||||||
agentId: '',
|
agentId: '',
|
||||||
conditionKind: 'ROUTE_METRIC',
|
conditionKind: 'ROUTE_METRIC',
|
||||||
condition: { kind: 'ROUTE_METRIC' } as Partial<AlertCondition>,
|
// Pre-populate a valid ROUTE_METRIC default so a rule can be saved without
|
||||||
|
// the user needing to fill in every condition field. Values chosen to be
|
||||||
|
// sane for "error rate" alerts on almost any route.
|
||||||
|
condition: {
|
||||||
|
kind: 'ROUTE_METRIC',
|
||||||
|
scope: {},
|
||||||
|
metric: 'ERROR_RATE',
|
||||||
|
comparator: 'GT',
|
||||||
|
threshold: 0.05,
|
||||||
|
windowSeconds: 300,
|
||||||
|
} as unknown as Partial<AlertCondition>,
|
||||||
evaluationIntervalSeconds: 60,
|
evaluationIntervalSeconds: 60,
|
||||||
forDurationSeconds: 0,
|
forDurationSeconds: 0,
|
||||||
reNotifyMinutes: 60,
|
reNotifyMinutes: 60,
|
||||||
|
|||||||
Reference in New Issue
Block a user