When defining an Observation. you must configure where to send events to via the Send events to options:
The following subsections outline the various options for handling data within an Observation.
Observations defined on an Octave edge device, can be configured to route events directly to the cloud, where they are stored in a Stream. From here they can be optionally processed in the cloud using a Cloud Action.
The steps below describe how to configure an Observation to route events directly to the cloud. In this example, the Observation is configured to read the value from the mangOH Red's built-in light sensor, and send an event with its value immediately to the cloud:
- Create or edit an Observation for the /redSensor/light/value sensor resource.
- Configure the Observation to send events to the cloud stream by setting Send events to to Cloud Stream.
- Click Save to save the Observation.
- Navigate to Build > Device > Streams and locate the new stream corresponding to the Observation created above.
- Click on the stream and inspect its events.
An event is stored in a stream with additional meta-data including the time at the edge, as well as the time received in the cloud. Having both of these times available for each event is important for more sophisticated data orchestration strategies.
While some data benefits from being sent to the cloud instantly, there is a cost for choosing to do so. Firstly, every time you start and stop the cellular data session, power is consumed. Secondly, encapsulating each reading for transmission individually, causes more data to be sent over the air and this is reflected in pricing.
In order to optimize power and bandwidth consumption, you can chose to have your readings stored and forwarded on a periodic basis. The Cloud Interface provides a buffer for events that you wish to store, and allows you to dynamically configure how often that buffer is sent to the cloud. This is referred to as store and forward.
Configuring store and forward involves setting the maximum time between transmissions via the
/cloudInterface/store_forward Resource. For example, if the store and forward buffer is set for 60 seconds and a "cloud stream" event is generated 30 seconds after the last transmission, the contents of the buffer will be sent with the "immediate" event, and the 60 second timer resets.
The steps below illustrate how to configure the maximum time between transmissions for store and forward, and how to modify an Observation to use store and forward:
- Locate the cloudInterface > store_forward Resource and set its Period property (e.g., to 60). This controls how often the Resource is polled.
- Click Set to save the update.
- Create or edit an Observation.
- Set Send events to to Store & Forward and click Save. Octave returns to the Observation listing screen.
- Verify that the Destination column for the edited Observation indicates Cloud immediately on this listing screen.
- Wait for 60 seconds for the timer to elapse to ensure that the value has been sent to the cloud.
- Navigate to Build > Device > Streams and locate the stream corresponding to the Observation.
- Click on an event to display its details. Note the time values for Generated date and Creation date which should be approximately 60 seconds or more apart.
Observations defined on an Octave edge device can be configured to process events directly on the device using an Edge Action, thus avoiding a data transfer to the cloud.
The steps below illustrate how to configure the Observation to send values to an Edge Action:
- Create or edit an Observation for the Resource (e.g., /lcd/text1).
- Set Send events to to Edge Action.
- Click Save.
- Follow the steps here to set up an Edge Action for the Observation to process events on the device.
An Observation can be configured to send events directly to another Resource rather than sending them to an Edge Action for processing at the edge, or to the cloud for processing by a Cloud Action. This is useful in cases where you need to forward events directly from one Resource to another (e.g., to send the value of a Sensor or Input to the mangOH Red's LCD screen). An Observation for the destination Resource can then be used to process the event.
The steps below illustrate how to configure an Observation to send events to another Resource. In this example, the Observation creates events from the mangOH Red's built-in light sensor and sends them to the Resource for the mangOH Red's built-in LCD screen:
- Create or edit an Observation for the /lcd/text1 output resource.
- Set Send events to to Resource.
- Click on the Destination resource drop down to display the Resources and select
- Enter an Observation name and click Save. The second line of text on the LCD should change to indicate the current light level.
The sections above described how to configure an Observation to send events to other destinations (e.g., to the cloud, to another resource, etc.). However, sometimes it can be useful to store data and query it at a later point. This is done by configuring an Observation with a buffer and choosing to store the data rather than sending it onward. The Observation can then be queried programmatically from an Edge Action associated with another Observation.
The steps below illustrate how create an Observation to store data, and how to query that data from and Edge Action:
- Create or edit an Observation for the /redSensor/light/value Sensor Resource.
- Configure the Observation to send events to Device Storage and to buffer 100 events.
- Create an Edge Action and add code to it that invokes Datahub.query() to get the buffered event data from the Observation created above. The following shows an example:
//Query the Datahub for the mean buffered event value var queryResult = Datahub.query('my_observation', 'mean', 10000)
Updated 6 months ago