Replies: 1 comment
-
Use a rule pipeline, one to calculate the average and another to evaluate the consequtive match case. #1 Create the source stream
{"sql" : "create stream demo () WITH (DATASOURCE=\"demo\", FORMAT=\"JSON\")"}
#2 Create rule to calculate the average value and publish to another stream
{
"id": "rule1",
"sql": "SELECT avg(temperature) FROM demo GROUP BY TumblingWindow(ss, 60)",
"actions": [{
"log": {
},
"memory": {
"topic": "relay/avg"
}
}]
}
#3 Create a stream from the memory topic to get the average value streams
{"sql" : "create stream avgStream () WITH (DATASOURCE=\"relay/avg\", FORMAT=\"JSON\", TYPE=\"memory\")"}
#4 Create a rule to check continuous alert
{
"id": "rule2",
"sql": "SELECT 1 as alert FROM avgStream GROUP BY CountWindow(3, 1) FILTER (WHERE avg > 25) HAVING count(*)=3",
"actions": [{
"log": {
}
}]
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
假如一个温度传感器,想对他设置这样的告警规则,每分钟会对他数次取值,然后计算它的平均值,一分钟算一个周期,如果3个周期内,平均值都大于25,那么就触发告警规则,应该使用哪种时间窗口?
用ekuiper能否做相应处理?
Scenario Description
If a temperature sensor wants to set up such an alarm rule, it will be sampled several times per minute and then calculate its average value. One minute is considered as one cycle. If the average value is greater than 25 for three consecutive cycles, the alarm rule will be triggered.
Sample Data
Assume event interval is 20 seconds, so 3 events is a minute.
Expect Output
The average temperature for each minute would be
An alarm will trigger at ts 240 and ts 300, because consecutive 3 minutes average are bigger than 25.
Beta Was this translation helpful? Give feedback.
All reactions