Overview
The Event Engine provides transition-based event generation for the system. Events are emitted ONLY when asset state changes, never for sustained states. This ensures clean event logs and prevents notification spam.Events are returned as part of the Sensor History response, not from a dedicated endpoint.Endpoint:
GET /api/v1/data/history/{asset_id}Response Field: events arrayEvent Types
ANOMALY_DETECTED
Emitted when an asset transitions from healthy to faulty state. Trigger: Sensor readings deviate from baseline by >25% tolerance for 2+ consecutive evaluations. Severity:critical
Example Messages:
"ANOMALY: High vibration variance (mechanical jitter): σ=0.0890g; Vibration transient spike: peak-to-peak=0.310g.""ANOMALY: Voltage spike detected (245.2V); Current surge detected (22.5A); Power factor degradation (0.78).""ANOMALY: Sensor readings have deviated from the established baseline."(generic fallback)
ANOMALY_CLEARED
Emitted when an asset transitions from faulty to healthy state. Trigger: All sensor readings return within baseline tolerance for 2+ consecutive evaluations. Severity:info
Example Message:
"RECOVERY: All sensor readings have returned to within normal operating range."
DEGRADATION_WARNING
Emitted when the Degradation Index (DI) crosses threshold milestones: 15%, 30%, 50%, 75%. Trigger: Cumulative degradation accumulation (Phase 20 prognostics). Severity:warningfor 15% and 30% thresholdscriticalfor 50% and 75% thresholds
"Motor fatigue reached 15% (DI=0.1523). Remaining Useful Life: 680.2h.""Motor fatigue reached 50% (DI=0.5012). Remaining Useful Life: 120.5h.""Motor fatigue reached 75% (DI=0.7534). Remaining Useful Life: 18.3h."
HEARTBEAT
(Reserved for future use - not currently implemented) Planned for periodic health check confirmations during extended healthy periods.Event Schema
ISO 8601 timestamp when the event occurred.Example:
"2026-03-02T15:42:30.123456Z"Event type identifier:
ANOMALY_DETECTEDANOMALY_CLEAREDDEGRADATION_WARNINGHEARTBEAT(reserved)
Event severity level:
info- Normal operational eventswarning- Early warnings requiring attentioncritical- Urgent issues requiring immediate action
Plain-English diagnostic explanation of what changed and why.For
ANOMALY_DETECTED events, the message includes:- Batch features (Phase 5): Variance, peak-to-peak ranges, statistical anomalies
- Raw signals: Voltage spikes/drops, current surges, power factor degradation, vibration levels
- Limited to top 4 deviations for readability
Diagnostic Message Components
Batch Statistical Features (Phase 5)
The Event Engine inspects batch features to identify WHY sensors are abnormal:Vibration variance (mechanical jitter detection)Threshold:
> 0.06 (healthy ≈ 0.02)Message: "High vibration variance (mechanical jitter): σ=0.0890g"Vibration transient spikesThreshold:
> 0.25 (healthy ≈ 0.10)Message: "Vibration transient spike: peak-to-peak=0.310g"Voltage variance (grid instability)Threshold:
> 5.0 (healthy ≈ 2.0)Message: "High voltage variance (grid instability): σ=8.30V"Voltage transient eventsThreshold:
> 15.0 (healthy ≈ 8.0)Message: "Voltage transient: peak-to-peak=28.5V"Current draw instabilityThreshold:
> 3.0 (healthy ≈ 1.0)Message: "Current draw instability: σ=4.20A"Power factor oscillation (load instability)Threshold:
> 0.04 (healthy ≈ 0.01)Message: "Power factor oscillating (load instability): σ=0.0450"Raw Signal Checks
Healthy Range: 220-240VMessages:
"Voltage spike detected (245.2V)"(> 240V)"Voltage drop detected (215.3V)"(< 220V)
Healthy Range: 12-18AMessages:
"Current surge detected (22.5A)"(> 18A)"Current drop detected (10.2A)"(< 12A)
Healthy Threshold: ≥ 0.88Message:
"Power factor degradation (0.78)" (< 0.88)Healthy Threshold: ≤ 0.25gMessage:
"Vibration spike (0.52g) — possible bearing wear" (> 0.25g)Debouncing Mechanism
Phase 7 Enhancement: Events require 2 consecutive matching evaluations before confirming a transition.At 1 evaluation/second, this equals 2 seconds of debouncing.Purpose: Prevent false positives from transient noise or Gaussian fluctuations.Example:
Event Examples
Anomaly Detection with Batch Features
Anomaly Detection with Raw Signals
Recovery Event
Degradation Threshold Events
State Tracking
The Event Engine maintains a thread-safe, per-asset state tracker (singleton):- Seeds
previous_is_faultywithout emitting an event - Prevents false positive on system startup
- Compares
is_faultyagainstprevious_is_faulty - Increments debounce counters
- Emits event only after debounce threshold met
Integration Workflow
Event Consumption
Real-Time Alerts
Event Log UI
Webhook Integration
Related Endpoints
- Sensor History - Primary endpoint that returns events
- Health Status - Get current degradation state and RUL
Related Documentation
- Event Engine Architecture - Detailed state machine design
- Phase 5: Batch Features - Statistical feature extraction
- Phase 7: Debouncing - False positive suppression
- Phase 20: Prognostics - Cumulative degradation tracking