Skip to main content

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

  1. Follow the instructions from the Quickstart tutorial up to the subscriptions section.
    Your metrics.sqrl script should look like this and your metricsapi.graphqls GraphQL schema should look like this.
  2. 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)
  3. Wait until the service is up and running (this takes a few minutes), then refresh this webpage to connect to the service.
  4. Open GraphiQL in your browser and invoke the mutation to metrics with high temperatures:
    mutation addReading {
    AddReading(metric: {
    sensorid: 1,
    temperature: 57.2
    }) {
    sensorid
    _source_time
    }
    }
    Run the mutation repeatedly with different input data (only temperatures above 50° trigger an alert).
  5. 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 IDTime (UTC)Temperature