Congratulations on successfully completing the stateless Siddhi App deployment scenario!

Stateless Siddhi App

Step 1 of 4

Introduction

This scenario presents how to deploy and run a stateless Siddhi Application on Kubernetes that receives HTTP requests and logs them.

This scenario is implemented using the PowerSurgeDetection app presented below.

@App:name("PowerSurgeDetection")
@App:description("Consumes HTTP messages in JSON format and logs them, if the device type is 'dryer', and the power level is greater than or equal 600W.")

@source( type='http', 
         receiver.url='${RECEIVER_URL}',
         basic.auth.enabled='false', 
         @map(type='json'))
define stream DevicePowerStream(
              deviceType string, power int);

@sink(type='log', prefix='LOGGER')  
define stream PowerSurgeAlertStream(
              deviceType string, power int);

@info(name='power-filter')  
from DevicePowerStream[deviceType == 'dryer' 
                       and power >= 600] 
select deviceType, power  
insert into PowerSurgeAlertStream;

Graphical View of PowerSurgeDetection App

The above app consumes JSON messages via HTTP sink in the format { 'deviceType': 'dryer', 'power': 6000 }, and inserts them into DevicePowerStream stream. From which the surge-detector query filters the events having device type dryer and the power consumption amount greater than or equals to 600W, and inserts them into the PowerSurgeAlertStream stream. The PowerSurgeAlertStream stream then logs them on the console using a log sink.

This app is stateless as it only has an HTTP source to consume events, a filter query, and a log sink.

For more information in developing Siddhi Apps, refer the Siddhi Documentation.

Prerequisites for deploying the app

  • Ingress - To receive HTTP/HTTPS requests into Siddhi Apps running on Kubernetes
  • Siddhi Operator - For deploying and managing Siddhi Apps on Kubernetes.

Deployment Architecture

The deployment architecture of the PowerSurgeDetection App will be as follows.

Deployment Architecture

Here, the HTTP/HTTPS requests to the Siddhi App are sent through the NGINX ingress controller.

The next section provides instructions on installing the prerequisites.