Type: reference · Imported reference (adopted from the clarity backend developer docs)
All routes are under /exactapi/monitor. If the monitoring subsystem failed to initialize, every route returns 501. Errors map to 400/404/500. See Monitor for the conceptual model.
Collection IDs are
org/site/unit/gridand contain/, so they are URL-encoded in path parameters.
/exactapi/monitor/alarm/snapshotFull alarm snapshot (all collections, all tag states, tick metadata).
/exactapi/monitor/alarm/summary?collection_id=Aggregated summary. With collection_id:
{ "collection_id": "org1/s1/u1/g1", "triggered_tags": 2, "total_tags": 40, "timestamp_ms": 1700000000000 }
Without it:
{ "collection_count": 12, "triggered_tags": 5, "timestamp_ms": 1700000000000,
"tick_number": 84213, "evaluation_duration_ms": 7 }
/exactapi/monitor/alarm/triggered-only?collection_id=Only triggered tags:
{ "timestamp_ms": 1700000000000, "collections": [ /* triggered tags only */ ], "total_triggered": 5 }
/exactapi/monitor/alarm/events/active{ "events": [ /* AlarmEvent */ ], "total_count": 3 }
/exactapi/monitor/alarm/events/stats?from_ms=&to_ms=Both params required.
{ "total_events": 120, "open_count": 3, "closed_count": 117,
"avg_duration_ms": 42000, "max_duration_ms": 360000,
"by_collection": [ … ], "by_rule": [ … ] }
/exactapi/monitor/alarm/events/{event_id}One AlarmEvent, or 404. An AlarmEvent includes trigger_value, clear_value, peak_value, threshold, comparison, rule_type, status (OPEN/CLOSED), opened_at_ms, closed_at_ms, duration_ms, and metadata.
/exactapi/monitor/alarm/eventsQuery params: from_ms, to_ms, collection_id, tag_index, rule_id, status, limit (default 100, cap 1000), offset (default 0).
{ "events": [ … ], "total_count": 240, "has_more": true }
/exactapi/monitor/alarm/events/cleanupBody { "older_than_ms": 1699000000000 }. Deletes CLOSED events older than the cutoff.
{ "deleted_count": 88 }
/exactapi/monitor/rule — createAuto-registers the collection first. Request (CreateRuleRequest):
| Field | Type | Required | Default |
|---|---|---|---|
collection_id |
string | yes | |
tag_index |
int | yes | |
tag_name |
string | yes | |
name |
string | yes | (unique per collection+tag) |
description |
string | optional | "" |
enabled |
bool | optional | true |
rule_type |
string | yes | AllOfN | KOfN | Percentage | GOAT |
rule_config |
object | yes | type-specific (see below) |
window_duration_ms |
int | optional | 10000 |
missing_behavior |
string | optional | Skip | FailOpen | RequireMinPresent |
missing_threshold |
int | optional | |
unitsId |
int | optional |
rule_config by type:
// AllOfN
{ "threshold": 540.0, "comparison": "GreaterThan" }
// KOfN
{ "threshold": 540.0, "comparison": "GreaterThan", "k": 3, "min_present": 5 }
// Percentage
{ "threshold": 540.0, "comparison": "GreaterThan", "percentage": 80.0, "min_present": 5 }
// GOAT
{ "mode": "Value", "known_record": 600.0, "approach_margin_pct": 5.0 }
comparison ∈ GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, Equal, NotEqual.
Example:
{
"collection_id": "org1/s1/u1/g1",
"tag_index": 4, "tag_name": "SteamTemp", "name": "SteamTemp - High Limit",
"rule_type": "AllOfN",
"rule_config": { "threshold": 540.0, "comparison": "GreaterThan" },
"window_duration_ms": 60000, "unitsId": 8
}
Response 201: { "id": "<uuid>" }.
/exactapi/monitor/rule?collection_id=&tag_index=List rules. collection_id+tag_index → rules for that tag (incl. disabled); collection_id only → enabled rules for the collection; neither → all rules. Returns an array of rule objects.
/exactapi/monitor/rule/{id}One rule, or 404.
/exactapi/monitor/rule/{id}Body = CreateRuleRequest (same fields). { "ok": true } or 400.
/exactapi/monitor/rule/{id}{ "ok": true } or 404.
| Method | Path | Body | Response |
|---|---|---|---|
| GET | /exactapi/monitor/config |
— | { "enabled": true } |
| PUT | /exactapi/monitor/config |
{ "enabled": false } |
{ "ok": true } |
| GET | /exactapi/monitor/collections |
— | [ { "id", "enabled", "description", "tick_rate_ms" } ] |
| PUT | /exactapi/monitor/collections/{id}/enable |
{ "tick_rate_ms"? } |
{ "ok": true } |
| PUT | /exactapi/monitor/collections/{id}/tick-rate |
{ "tick_rate_ms" } |
{ "ok": true } (400 if < 100) |
| PUT | /exactapi/monitor/collections/{id}/disable |
— | { "ok": true } |
| GET | /exactapi/monitor/status |
— | { "enabled", "collection_count", "rule_count", "last_snapshot_ms", "tick_number" } |
Adopted from clarity backend developer docs (
docs/developer/api/monitoring.md), imported reference.
Primary handler:clarity:backend/src-tauri/src/monitor/api.rs.
Last updated: 2026-07-16 from clarity@bff451d