Monitors
定義要看的事,不管理內部 Session
Monitor 是持久化任務,綁定 Source 與自然語言 prompt。公開 mon_* ID 在 Runtime 重新啟動與內部 Session 重建後保持不變。
建立 Monitor
curl -X POST http://localhost:8000/v1/monitors \
-H "Authorization: Bearer $SENTINEL_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: loading-dock-after-hours" \
-d '{
"name": "After-hours loading dock",
"source_id": "src_01...",
"prompt": "Notify when a person enters the loading area after hours.",
"enabled": true
}'一套 API,多個場景
夜間入侵、禁區、跌倒、滯留與裝卸區安全不是不同產品。它們共用相同 Source、Monitor、Event 與 Webhook 契約;目前 API 以 prompt、推理 cadence 與 metadata 表達差異。
{
"name": "Restricted area",
"source_id": "src_01...",
"prompt": "Notify when a person enters the restricted area.",
"language": "en",
"inference_window_ms": 5000,
"inference_frames_per_window": 1,
"analytics": {
"enabled": true,
"show_boxes": true,
"show_count": true,
"local_tracking": true,
"show_dwell": true,
"use_as_ai_context": false,
"traffic": {
"enabled": true,
"subject_labels": ["person"],
"stopped_seconds_threshold": 5,
"event_release_seconds": 10,
"motion_threshold": 0.015,
"optical_flow_enabled": false,
"road_roi_polygons": [],
"exclusion_polygons": [],
"tripwires": []
}
},
"enabled": true
}目前 create/patch schema 包含 prompt、language、inference cadence、analytics 與 metadata。Analytics 可設定 detector、local tracking、traffic ROI、exclusion zones、tripwires、停留門檻與 optical flow;未列出的欄位不屬於公開契約。
期望狀態與執行狀態
enabled: true | false
desired_state: running | stopped
runtime_state: stopped | starting | running | waiting_for_source |
waiting_for_model | degraded | failed暫時來源或模型故障不會刪除 Monitor。Runtime 保留期望狀態,在依賴恢復或節點重啟後重新協調。
控制與測試
POST /v1/monitors/{monitor_id}/start
POST /v1/monitors/{monitor_id}/stop
POST /v1/monitors/{monitor_id}/testtest 應走真實 Monitor 驗證路徑並回報可執行性,不會偽造模型成功。Start/stop 修改期望狀態;關閉可選 UI 不等於 stop。
提示詞是設定資料,不是公開事件 schema。下游程式應依 Event type、severity、state 與 attributes 工作,不要解析 prompt 或模型 prose。