Creating Datastreams

📘

This page contains

  • The start of your journey through managing sensors on Senaps
  • How to build a Datastream, through the GUI and API

Build a Datastream

The first step to organise your sensor network in Eratos Senaps is to create the data structures to house the incoming data, called Datastreams. Datastreams are highly optimized time series storage units, ideal for fast, integrated handling of timeseries data like temperature. Each stream maps one-to-one with a specific measured quantity.

To build a Datastream, navigate to the Senaps datastreams page, under the Data heading, and click "+ Add a New Stream" You should be met with this configuration page:

📘

Note:

If you haven't set up some of the meta-data structures, like location, you can always edit the stream later once you have. How to build these structures is covered here.

At minimum, a data stream needs Id,Result Type,Organisation and Interpolation Type.

Where,

  • Id: A unique id for the stream. The eratos convention is as follows: organisation.group.platform.variable
    • For example: eratos-internal.example-group.weatherstation.one.air-temperature
  • Result type: The type of data stored in the data stream. More information on available types can be found here.
  • Organisation: The organisation this stream will be associated with.
  • Groups: A metadata structure to help organise associated datastreams.
  • Location: A metadata object denoting the location of the stream data origin.
  • Sample Period: The period of time the datastream will be receiving data for (leave blank for indefinite)
  • Reporting Period: The period of time the datastream will be receiving data for (leave blank for indefinite)
  • Observed Property: a Uniform Resource Identifier (URI) for the variable the stream is measuring
  • Unit of Measure: a Uniform Resource Identifier (URI) for the unit that the stream is measuring in
  • Interpolation type: How should the stream interpreted the values between data points?
    For more information about interpolation types see this page.
  • Metadata (Optional): A place to store custom metadata about the stream in a JSON structure

Fill in the required fields, and click Create Stream. Well done, that's your first stream created.

Creating Datastreams Via the Eratos API

Sometimes its useful to use the Eratos API to generate the datastreams. There is a few reasons why this may be the case:

  • Programmatic/ automatic generation
  • Richer configuration options and meta-data

Below is a recipe to generate several datastreams, by making a PUT API request, this script can be reconfigured to suit your needs.

A link to more detailed API tutorial can be found here.
import json
import requests
import pprint


### User Information ### 
senaps_key = '<ENTER YOUR SENAPS KEY HERE>'

stream_names = ['put.your.stream.names.here', 'you.can.create.many.at.a.time']

org_id = '<ENTER ORG ID HERE>'
############################

senaps_url_intro = 'senaps' 
for stream in stream_names:

    stream_id = f"{stream}"

    payload = {
    "id": stream_id,
    "resulttype": "scalarvalue", #This can be changed depending on the data type
    "organisationid": org_id,
    "streamMetadata": {
        "type": ".ScalarStreamMetaData",
        "interpolationType": "http://www.opengis.net/def/waterml/2.0/interpolationType/Continuous" #This can be changed depending on the intepolation type
    },
    "usermetadata": {} #Enter custom meta data here
    }

    url = f"https://{senaps_url_intro}.eratos.com/api/sensor/v2/streams/{stream_id}"

    headers = {
    'apikey': senaps_key
    }

    response = requests.request("PUT", url, headers=headers, json=payload)
    response.raise_for_status()
    json_resp = json.loads(response.text)

    pprint.pprint(json_resp)

What’s Next

Create the meta data structures to manage a sensor fleet.