Thin-edge.io and Apama Community Edition

thin-edge.io is brand-new open-source software developed collaboratively by several partners, including Software AG. It offers a lightweight framework for device management and connecting devices to cloud providers with mappings to connect to many cloud providers available out-of-the-box, including for Cumulocity IoT. Apama can be used alongside thin-edge.io to provide on-device fast, real-time analytics including pre-processing, aggregation, filtering, and more.

Getting Started

The best way to get your device set up is to follow the instructions for using Apama Community Edition with thin-edge.io in thin-edge.io’s examples GitHub repository which will walk you through setting up a Raspberry Pi with thin-edge.io and Apama Community Edition and deploying a simple project. In the repository, we have provided a service script that can be used to start the correlator as a service and run your project with a single command. We have also created some more interesting sample projects. Once you have your thin-edge device configured, you can replace the basic project with any of these or deploy a custom project from a full installation of Apama Community Edition. Let’s have a quick look at the current sample offering.

The Limited Bandwidth sample project

The Limited Bandwidth sample project demonstrates a solution for situations where it is excessive or unnecessary to send all data from end devices to the cloud and what is required are aggregations or intermediate measurements, especially in cases where readings might be taken on millisecond timescales. Often we are only interested in the average over some longer duration or want updates only once per minute/hour/day or another larger timeframe and to drop other intermediate measurements. The Limited Bandwidth sample project uses Apama’s streams to average temperature, pressure, and vibration over five-second intervals and forwards these averages to the cloud.

The Resource Monitoring sample project

Sometimes we may be interested in a measurement only if it exceeds a certain threshold or we may want an alert on a shorter timescale only if some threshold is exceeded, but otherwise require more sporadic updates. With the Resource Monitoring sample project, we monitor CPU and memory usage on the thin-edge device using Apama. If the usage exceeds 70%, for at least 70% of the time over a five-minute interval, the percentage of time spent exceeding that threshold is forwarded to the cloud (note that in this sample project we are not sending the average use, but the percentage of time spent exceeding the threshold). If no update has been triggered within a period of one hour, a report is generated of the percentage of time exceeding the threshold during that hour.

Deploying your custom project

Once you have tried running the sample projects, or if you are already a seasoned Apama developer, you will probably want to create your own projects for your thin-edge device. We recommend ensuring that you have deployed the project either with Software AG Designer or engine_deploy which will ensure that the initialization list for the correlator is correctly ordered.

Some things to remember when creating your project:

  1. thin-edge.io comes packaged with Mosquitto MQTT broker which operates on the default MQTT port of 1883.
  2. Measurements that you wish to send to the cloud provider must be:
    2.1. Published to the tedge/measurements topic.
    2.2. Published in the Thin Edge JSON format as this is what allows thin-edge.io to be able to support multiple cloud providers.

The thin-edge.io Apama Plugin

The thin-edge.io team has provided a plugin for Apama with their 0.5.0 release. With this plugin, you can update and redeploy projects to Apama running on edge devices remotely from the Cumulocity IoT web interface. A demonstration of the plugin can be found in the video below at 16 minutes.