Streaming Analytics Options in Cumulocity IoT

Introduction

Many IoT Solutions (if not all) need to perform some real-time analytics on their connected devices data. Cumulocity IoT offers different tools to achieve this; starting from the very-straightforward smart rules, moving to a more business-user approach with the Analytics Builder app, followed by its more in-depth EPL App tool which is primarily focused for developers and finishing with a full blown Apama solution by creating a microservice. This article explains all the different Streaming Analytics options and when to use what.

Smart Rules

Smart rules is a capability in Cumulocity IoT allowing a user to enable pre-defined business rules on incoming real-time data and to perform some actions based on this data. These rules can be configured and enabled by domain experts via simple dialogs in the Cockpit application. Behind the hood, these rules are actually implemented using the EPL language and injected into the Apama correlator but all of this is transparent to the user.

You want to use smart rules when the pre-defined rules are sufficient for your business needs. They can be enabled at device/group level or for all devices.

Analytics Builder

Analytics Builder gives engineers and domain experts a web-based capability to develop analytics application on streaming data without coding. The users can combine logic blocks together to build powerful models to process data in real-time. Analytics Builder offers a large range of pre-built blocks which the users can drag and drop onto a canvas, configure them with a few clicks and link the blocks to one another to create an end-to-end business logic. There is also the possibility to create your own blocks using our Analytics Builder SDK. The combination of all the blocks in the canvas is called a Model.
Models can be developed easily in minutes, edited and tested within the Cumulocity IoT environment. You can also test your analytics models with simulated or historical data and deploy them with a single-click. You can execute the same model from different devices in parallel. Model execution is also handled by Apama behind the scenes.

Analytic Builder models can be much more powerful and customizable than the smart rules templates included in Cumulocity IoT, and they are quicker and simpler to develop than writing Apama EPL code. You will want to use Analytics Builder when the existing smart rules are not enough to do the analysis required on the data or if, for example, you want to extend the devices’ data by adding new fragments, generate new types of events or measurements, trigger operations or much more based on a specific business logic. The tool is very easy to use and does not involve writing any lines of code so it is mainly aimed for business users or domain experts.

Note that with Analytics Builder, the model can run only on a device or a group of devices. At the time of writing, you cannot run a model over ALL the tenant’s devices.

EPL Apps

EPL Apps allows you to develop streaming analytics rules directly within Cumulocity IoT using the Apama EPL language. EPL Apps provides an interface to developers for interactively editing new or existing EPL applications. The rules need to be written in EPL as they will be directly injected as monitors into the Apama Correlator which runs on the tenant. The tool includes many examples to get you started in creating your own analytics rules. Every single EPL app is stateless and independent to one another; meaning a rule should have its own business logic without being dependent of another rule (they should not share events). This is one of the limitations imposed on EPL apps due to the Cumulocity IoT environment.

EPL Apps should be used by developers who are happy to write code in EPL. You want to choose EPL apps when the analytics you want to perform is quite advanced and cannot be easily implemented using Analytics Builder. Also, with EPL apps, the real-time analytics can be run over ALL your devices, whereas in Analytics Builder you can run the model only on one single device or a group of devices. EPL apps can be much more advanced than smart rules and Analytics Builder models and they can be much more flexible and powerful in terms of analytics possibilities. Just as an example, you can call external APIs over HTTP and handle their responses using an EPL app…

Apama Microservice

Smart rules, Analytics Builder and EPL Apps all use the Streaming Analytics microservice behind the scenes which is provided with Cumulocity IoT. This microservice is doing a lot of the work for you, receives the devices data in real-time and persists whatever is required in the platforms operational store (MongoDB). However, if needed, you can also use Apama within your own custom microservice.

As a developer you would want to build you own custom microservice in case you need to create a large Apama solution similar to a standalone application. The microservice would include Apama and be comprised of multiple EPL monitors exchanging data to one another and potentially connecting to several external systems too. The usage of an IDE and the Cumulocity IoT connectivity plug-in will be required so you can easily connect to Cumulocity IoT and make use of its domain model.

However we usually do not typically recommend creating your own custom microservice including Apama. First of all, most of the analytics required should be achievable via the 3 previous options. But most of all, Apama uses the Cumulocity IoT real-time notification API for the ingestion of data and this mechanism is not considered reliable for production use cases. This means your microservice could miss some Cumulocity IoT events such as Measurements, Alarms etc… These reliability issues do not exist with the main Apama-ctrl microservice (the one being provided with Cumulocity IoT) because the Cumulocity IoT data is pushed to this microservice via a dedicated endpoint over REST.

Conclusion | Next steps

Cumulocity IoT offers a wide range of options to create your own streaming analytics over the device data. Those options go from the simplest interface for non-coders to a more in-depth hands-on developer tool for technical people. Whatever your streaming analytics need are, you can build it with a single or a combination of these streaming analytics options described here.

If you want to learn more about EPL and go more in depth on every single option, then you might be interested in some of our Training courses or Fast Track Services which will allow you to learn much more about Apama and provide hands-on exercises.

Useful links | Relevant resources

Apama Advent Calendar
Apama Limitations in Cumulocity

4 Likes