SurrealDB, time series, event triggers, graph
Start the DB with:
surreal start -u root -p rootImport the schema:
surreal import -e http://localhost:8000 -u root -p root \
--namespace telemetry-simulator --database demo \
surql/migrations/0.schema.surqlAdd initial data:
surreal import -e http://localhost:8000 -u root -p root \
--namespace telemetry-simulator --database demo \
surql/migrations/1.initial_data.surqlCreate the event trigger:
surreal import -e http://localhost:8000 -u root -p root \
--namespace telemetry-simulator --database demo \
surql/migrations/2.sensor_anomaly_alert.surqlRun the simulated devices with:
just simRun 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;


