Metrics Subscription Demo
This page demonstrates how to consume the metrics subscription from the Quickstart tutorial
Follow the instructions below to build realtime updates with DataSQRL.
Instructions
- Follow the instructions from the Quickstart tutorial up to the subscriptions section.
Yourmetrics.sqrl
script should look like this and yourmetricsapi.graphqls
GraphQL schema should look like this. - Compile and run the script with the commands:
docker run --rm -v $PWD:/build datasqrl/cmd compile metrics.sqrl metricsapi.graphqls;
(cd build/deploy; docker compose up) - Wait until the service is up and running (this takes a few minutes), then refresh this webpage to connect to the service.
- Open GraphiQL in your browser and invoke the mutation to metrics with high temperatures:Run the mutation repeatedly with different input data (only temperatures above 50° trigger an alert).
mutation addReading {
AddReading(metric: {
sensorid: 1,
temperature: 57.2
}) {
sensorid
_source_time
}
} - You should see data appear in the table to the right. Check the console logs for errors (your browser may block access to localhost).
High Temperature Alerts >50° (updated in realtime)
Sensor ID | Time (UTC) | Temperature |
---|