简体   繁体   English

wso2 cep Siddhiql

[英]wso2 cep Siddhiql

I have multiple sensors sending measurement events to a stream. 我有多个传感器将测量事件发送到流。 An event consists of {parameter, value, timestamp} . 事件由{parameter,value,timestamp}组成 I want to observe these values for a time window of few days and check the trends and make diagnostics about the equipment being monitored by these different sensors. 我想在几天的时间范围内观察这些值,并检查趋势并诊断由这些不同传感器监视的设备。

  1. Divide the streams by parameter. 按参数划分流。
from inputStream[parameter='A']
    select *
    insert into Astream;

and so on for each parameter being received. 对于每个接收到的参数,依此类推。

  1. for the timewindow, say 60 seconds, compute linear regression to find the change. 对于时间窗口(例如60秒),计算线性回归以查找更改。
from Astream#timeseries:lengthTimeRegress(60000, value, timestamp)
    select beta1 * 100 as AChange 
    insert into AChangeStream;

This I do for each metric stream. 我为每个指标流执行此操作。 3. Once I have trend for each stream, I collect the changed values for each stream and check if they meet the condition. 3.确定每个流的趋势后,我将收集每个流的更改值并检查它们是否满足条件。

from every e1=AChangeStream[e1.AChangeStream > 0.5], e2=BChangeStream[e2.BChangeStream  0.15]
    select 'condition 1 alarm' as message
    insert into alertStream;

Will the above siddhi ql detect the changes in 6 parameters in the time window? 上面的siddhi ql是否可以检测到时间窗口中6个参数的变化?

The gist of the query you have provided is correct except for few minor things you have missed. 您提供的查询的要旨是正确的,除了您错过的一些小事情。 When you say 6 parameters, I believe that you have something similar to Parameters A, B, C, D, E and F. Eventually you seem to want to find a sequence of events that match the given condition [1]. 当您说6个参数时,我相信您具有与参数A,B,C,D,E和F相似的东西。最终,您似乎希望找到一个符合给定条件的事件序列[1]。

Considering only 2 Parameters A and B, you could write the queries in Siddhi language as follows, to achieve your requirement. 仅考虑2个参数A和B,您可以按以下方式用Siddhi语言编写查询,以实现您的要求。

@Import('input:1.0.0')
define stream inputStream (parameter string, value double, timestamp long);    


from inputStream[parameter=='A']
select *
insert into Astream;    

from inputStream[parameter=='B']
select *
insert into Bstream;    

from Astream#timeseries:lengthTimeRegress(60000, 10000, value, timestamp)
select beta1*100 as AChange 
insert into AChangeStream;    

from Bstream#timeseries:lengthTimeRegress(60000, 10000, value, timestamp)
select beta1*100 as BChange 
insert into BChangeStream;    

from every e1=AChangeStream[e1.AChange > 0.5], e2=BChangeStream[e2.BChange > 0.15]
select 'condition 1 alarm' as message
insert into alertStream;

Please note the following. 请注意以下事项。

  1. In lengthTimeRegress function, you need to provide 4 mandatory parametrs, as specified in [2]. 在lengthTimeRegress函数中,您需要提供4个强制性参数,如[2]中所指定。 You have missed the batch size in the query you have written. 您在编写的查询中错过了批次大小。 The maximum number of events to be used for a regression calculation is specified by the batch size. 批处理大小指定了用于回归计算的最大事件数。
  2. In the sequence condition, you need to use a parameter. 在顺序条件下,您需要使用一个参数。 Not the stream name. 不是流名称。 What you have mistakenly written as e1.AChangeStream > 0.5 must change as e1.AChange > 0.5 您错误地写为e1.AChangeStream> 0.5的内容必须更改为e1.AChange> 0.5

[1] https://docs.wso2.com/display/CEP420/SiddhiQL+Guide+3.1#SiddhiQLGuide3.1-Sequence [1] https://docs.wso2.com/display/CEP420/SiddhiQL+Guide+3.1#SiddhiQLGuide3.1-Sequence
[2] https://docs.wso2.com/display/SIDDHIEXTENSIONS/Regression [2] https://docs.wso2.com/display/SIDDHIEXTENSIONS/Regression

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM