Skip to content

CepBolt

The CepBolt (ComplexEventProcessing Bolt) lets you insert Siddhi rules in your data streams.

To deploy a Siddhi rule, you must bring to the rule the right stream(s) and fields. Notice that there is a natural correlation between Siddhi amd storm concepts. In fact the Siddhi rule engine has been designed for being integrated into Storm.

If your rule matches some condition, it will emit some new events. These will be emit in a corresponding Storm stream.

You can then place some downstream bolts to take care of data formatting, additional processing, and finally plug some output bolt (a KafkaBolt or an ElasticsearchBolt) to forward the results to the right destination.

Here is an example configuration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{
    "type": "cep_bolt",
    "bolt_settings": {
       "rule" : "my_siddhi_rule.rule"
    },
    "storm_settings": {
       "executors": 1,
       "component": "my_cep_bolt",
       "subscribe": [ {
          "component": "some_source_spout",
          "stream": "input",
          "grouping": "localOrShuffle"
       } ]
    }
 }

Where my_siddhi_rule.rule refers to a rule stored under the platform resources/siddhi folder

1
2
3
4
5
6
7
8
//
// Generate an event whenever a battery level drops lower than some threshold
//
define stream input (local_uuid string, battery float, deviceId int);
@info(name = 'query') from logs[battery < 0.2] \
  select battery, local_uuid, avg(battery) \
  as battery_avg group by deviceId \
  insert into output

Refer to the Cep Getting Started section

Streams And fields

Just like Storm, Siddhi works on data stream(s). The streams described in your rule must match the Storm streams subscribed by your Cep Bolt.

Correlation results will be emitted on the streams defined in the Siddhi rule. These output stream(s) can in turn be referred to by downstream bolts.

By default the Cep bolt also publishes the input data on the input stream, even if that input data does not match the rule condition. You can thus use a Siddhi rule as a proxy forwarding transparently a stream of data, and generating new stream(s) of data in case the rule condition matches.

Parameters

You specify your rule using one of the two following parameters.

  • rule : String : default_value > path of rule resource (prefixed by resources/siddhi) containing Siddhi
  • parameter2_name : type > explanation
  • plan : String > a siddhi plan, i.e. a complete rule description. You can specify an inline plan or use the rule parameter to specify the path of resource file.

Refer to the Cep Getting Started section

Limitations

Cep Bolt works on Storm fields. You cannot use nested fields, i.e. the rule can take only flatten values. If you need to use a nested field in a rule, use a punchlet in front of your Cep bolt to transform your nested field in one or several Storm field (do not forget to publish it).

Alternatively you can embed a Siddhi rule directly from within a punchlet.