Thin-edge.io and Apama Community Edition
Tags: apama, streaminganalytics
Published: 2022-03-21 09:54:05

---
title: Thin-edge.io and Apama Community Edition
published: true
date: 2022-03-14 09:14:40 UTC
tags: Apama, StreamingAnalytics
canonical_url: https://tech.forums.softwareag.com/t/thin-edge-io-and-apama-community-edition/254667
---


[thin-edge.io](http://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](http://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](https://github.com/thin-edge/thin-edge.io_examples/tree/main/StreamingAnalytics) in [thin-edge.io](http://thin-edge.io)’s examples GitHub repository which will walk you through setting up a Raspberry Pi with [thin-edge.io](http://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](https://github.com/thin-edge/thin-edge.io_examples/tree/main/StreamingAnalytics/LimitedBandwidth) 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](https://documentation.softwareag.com/apama/v10-11/apama10-11/apama-webhelp/index.html#page/apama-webhelp/tutorialStreams.html) 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](https://github.com/thin-edge/thin-edge.io_examples/tree/main/StreamingAnalytics/ResourceMonitoring) 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](http://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](https://github.com/thin-edge/thin-edge.io/blob/main/docs/src/architecture/thin-edge-json.md) format as this is what allows [thin-edge.io](http://thin-edge.io) to be able to support multiple cloud providers.

## The [thin-edge.io](http://thin-edge.io) Apama Plugin

The [thin-edge.io](http://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.

[https://www.youtube.com/embed/iPanFhe6vRk]
(https://www.youtube.com/embed/iPanFhe6vRk?autoplay=1&feature=oembed&wmode=opaque)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3s8v6s2wmva4we4ctdox.png)
 

[Visit original post](https://tech.forums.softwareag.com/t/thin-edge-io-and-apama-community-edition/254667)