🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(monitors): add Monitor Prisma schema and migration (#13677)
Mark Salpeter5e86ceb6aec4
diff --git a/packages/shared/prisma/migrations/20260518092907_add_monitors/migration.sql b/packages/shared/prisma/migrations/20260518092907_add_monitors/migration.sqlnew file mode 100644index 0000000000..e96b581ed4--- /dev/null+++ b/packages/shared/prisma/migrations/20260518092907_add_monitors/migration.sql@@ -0,0 +1,62 @@+-- CreateEnum+CREATE TYPE "MonitorThresholdOperator" AS ENUM ('GT', 'GTE', 'LT', 'LTE', 'EQ', 'NEQ');++-- CreateEnum+CREATE TYPE "MonitorView" AS ENUM ('OBSERVATIONS', 'SCORES_NUMERIC', 'SCORES_CATEGORICAL');++-- CreateEnum+CREATE TYPE "MonitorSeverity" AS ENUM ('UNKNOWN', 'OK', 'WARNING', 'ALERT', 'NO_DATA');++-- CreateEnum+CREATE TYPE "MonitorStatus" AS ENUM ('ACTIVE', 'PAUSED', 'ERROR_BAD_QUERY');++-- CreateTable+CREATE TABLE "monitors" (+ "id" TEXT NOT NULL,+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,+ "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,+ "created_by" TEXT,+ "updated_by" TEXT,+ "project_id" TEXT NOT NULL,+ "view" "MonitorView" NOT NULL,+ "filters" JSONB NOT NULL,+ "metric" JSONB NOT NULL,+ "window_ms" BIGINT NOT NULL,+ "cadence_ms" BIGINT NOT NULL,+ "threshold_operator" "MonitorThresholdOperator" NOT NULL,+ "alert_threshold" DECIMAL(65,30) NOT NULL,+ "warning_threshold" DECIMAL(65,30),+ "severity" "MonitorSeverity" NOT NULL DEFAULT 'UNKNOWN',+ "severity_changed_at" TIMESTAMP(3),+ "no_data" JSONB NOT NULL,+ "renotify" JSONB NOT NULL,+ "status" "MonitorStatus" NOT NULL DEFAULT 'ACTIVE',+ "scheduler_batch_id" BIGINT NOT NULL,+ "next_run_at" TIMESTAMP(3) NOT NULL,+ "last_published_run_at" TIMESTAMP(3),+ "last_completed_run_at" TIMESTAMP(3),+ "name" TEXT NOT NULL,+ "message" TEXT NOT NULL DEFAULT '',+ "tags" TEXT[] DEFAULT ARRAY[]::TEXT[],+ "alerted_at" TIMESTAMP(3),++ CONSTRAINT "monitors_pkey" PRIMARY KEY ("id")+);++-- CreateIndex+CREATE INDEX "monitors_project_id_idx" ON "monitors"("project_id");++-- CreateIndex+CREATE INDEX "monitors_scheduler_batch_id_idx" ON "monitors"("scheduler_batch_id");++-- CreateIndex+CREATE INDEX "monitors_scheduler_tick_idx" ON "monitors"("next_run_at", "scheduler_batch_id");++-- AddForeignKey+ALTER TABLE "monitors" ADD CONSTRAINT "monitors_created_by_fkey" FOREIGN KEY ("created_by") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "monitors" ADD CONSTRAINT "monitors_updated_by_fkey" FOREIGN KEY ("updated_by") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;++-- AddForeignKey+ALTER TABLE "monitors" ADD CONSTRAINT "monitors_project_id_fkey" FOREIGN KEY ("project_id") REFERENCES "projects"("id") ON DELETE CASCADE ON UPDATE CASCADE;diff --git a/packages/shared/prisma/schema.prisma b/packages/shared/prisma/schema.prismaindex 5ffe88353d..6e8d16a8d7 100644--- a/packages/shared/prisma/schema.prisma+++ b/packages/shared/prisma/schema.prisma@@ -70,6 +70,8 @@ model User {dashboardUpdated Dashboard[] @relation("UpdatedByUser")tableViewPresetCreated TableViewPreset[] @relation("CreatedByUser")tableViewPresetUpdated TableViewPreset[] @relation("UpdatedByUser")+ monitorsCreated Monitor[] @relation("CreatedByUser")+ monitorsUpdated Monitor[] @relation("UpdatedByUser")annotationQueueAssignment AnnotationQueueAssignment[]surveys Survey[]commentReactions CommentReaction[]@@ -160,6 +162,7 @@ model Project {triggers Trigger[]automationExecutions AutomationExecution[]Automation Automation[]+ monitors Monitor[]DefaultLlmModel DefaultLlmModel[]Price Price[]SlackIntegration SlackIntegration?@@ -1577,6 +1580,86 @@ model AutomationExecution {@@map("automation_executions")}+enum MonitorThresholdOperator {+ GT+ GTE+ LT+ LTE+ EQ+ NEQ+}++enum MonitorView {+ OBSERVATIONS+ SCORES_NUMERIC+ SCORES_CATEGORICAL+}++enum MonitorSeverity {+ UNKNOWN+ OK+ WARNING+ ALERT+ NO_DATA+}++// Scheduler evaluates only ACTIVE; any other state is skipped.+enum MonitorStatus {+ ACTIVE+ PAUSED+ ERROR_BAD_QUERY+}++model Monitor {+ id String @id @default(cuid())+ createdAt DateTime @default(now()) @map("created_at")+ updatedAt DateTime @default(now()) @updatedAt @map("updated_at")++ createdBy String? @map("created_by")+ createdByUser User? @relation("CreatedByUser", fields: [createdBy], references: [id], onDelete: SetNull)+ updatedBy String? @map("updated_by")+ updatedByUser User? @relation("UpdatedByUser", fields: [updatedBy], references: [id], onDelete: SetNull)++ projectId String @map("project_id")+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)++ // === Query shape (mirrors DashboardWidget, minus TRACES) ===+ view MonitorView+ filters Json+ metric Json++ // === Monitor Evaluation ===+ windowMs BigInt @map("window_ms")+ cadenceMs BigInt @map("cadence_ms")+ thresholdOperator MonitorThresholdOperator @map("threshold_operator")+ alertThreshold Decimal @map("alert_threshold")+ warningThreshold Decimal? @map("warning_threshold")++ severity MonitorSeverity @default(UNKNOWN)+ severityChangedAt DateTime? @map("severity_changed_at")++ noData Json @map("no_data")+ renotify Json++ // === Scheduling ===+ status MonitorStatus @default(ACTIVE)+ schedulerBatchId BigInt @map("scheduler_batch_id")+ nextRunAt DateTime @map("next_run_at")+ lastPublishedRunAt DateTime? @map("last_published_run_at")+ lastCompletedRunAt DateTime? @map("last_completed_run_at")++ // === Alerts ===+ name String+ message String @default("")+ tags String[] @default([])+ alertedAt DateTime? @map("alerted_at")++ @@index([projectId])+ @@index([schedulerBatchId])+ @@index([nextRunAt, schedulerBatchId], map: "monitors_scheduler_tick_idx")+ @@map("monitors")+}+// Slack Integration: Stores centralized Slack workspace connection for each project// One project can connect to one Slack workspace, supporting multiple channel automationsmodel SlackIntegration {