SurrealDB, time series, event triggers, graph
Start the DB with:
surreal start -u root -p root
Import the schema:
surreal import -e http://localhost:8000 -u root -p root \
--namespace telemetry-simulator --database demo \
surql/migrations/0.schema.surql
Add initial data:
surreal import -e http://localhost:8000 -u root -p root \
--namespace telemetry-simulator --database demo \
surql/migrations/1.initial_data.surql
Create the event trigger:
surreal import -e http://localhost:8000 -u root -p root \
--namespace telemetry-simulator --database demo \
surql/migrations/2.sensor_anomaly_alert.surql
Run the simulated devices with:
just sim
Run a live select to see alerts being raise in real time:
live select * from alert;
Graph queries:
-- Alerts per sensor
SELECT *, ->created_alert->alert FROM sensor;
-- Sensor locations
select *, ->located_at->site from sensor;
-- Alerts per site
SELECT
id,
<-located_at<-sensor->created_alert->alert.{message, outlier} AS alerts
FROM site
FETCH alerts;