基于Drools的CEP规则引擎实现
来源:互联网 发布:tv版直播软件 编辑:程序博客网 时间:2024/05/21 09:32
1,整体数据流程图
Agent负责数据的采集,通过远程过程调用,经Loastach到Kafka,Collector负责原始数据的整理,生成特定结构的数据体在持久化的同时由需要数据的业务消费。在被规则引擎消费时数据被处理为Rule Event,规则引擎CEP(Complex Event Processing,是复杂事件处理系统)根据特定规则Rule和事件生成规则事件,Common Event。
2,该模块在APM整体结构中的位置
3,CEP与系统交互设计
功能支持:
规则命名;规则有效性检查;事件统计;事件告警级别;告警级别变更报告;
接口:
规则的增删查改;规则包的生成;规则库的创建;规则包向规则库的推送;kafka事件获取;规则库中规则包的动态加载;告警事件输出到kafka;
4,详细设计
规则文件实例:
package com.aires.oespaas.cep.rules;import com.aires.oespaas.cep.common.model.ApmSourceEvent;import com.aires.oespaas.cep.common.model.ApmResultEvent;import com.aires.oespaas.cep.common.model.ApmResultSet;declare ApmSourceEvent @role(event) @Expires(10m) @Timestamp(timestamp)endrule "ResponseTimeRule" no-loop enabled true when $t1: ApmSourceEvent($objectName: objectname,["applicationlication=HelloWord"] contains $objectName,$objectType: objecttype == "applicationlication", $timestamp:timestamp,$metricName:metricname == "responsetime") $flag : Integer() from accumulate( $t2: ApmSourceEvent( objectname == $objectName, objecttype == $objectType, metricname == $metricName, $metricValue : metricvalue, this before[0m, 29m59s] $t1 ), init(int result = 10070;), action( if ($metricValue <=2000.0 && result <=10070) {result =10070;} else if ($metricValue >5000.0){result =10072;} else if ($metricValue >2000.0 && $metricValue <= 5000.0 && result !=10072){result =10071 ;} ), result( new Integer( result ) ) ) then String info = "rulename:rules_Res,applicationlication" + $metricName; String detail = ""; if($flag == 10070){ detail = info + ";ruledetail:calls< 2000.0 in last 30min;"; } if($flag == 10071){ detail = info + ";ruledetail: 2000.0<responsetime< 5000.0 in last 30min;"; } if($flag == 10072){ detail = info + ";ruledetail: responsetime>5000.0 in last 30min;"; } channels["apmDefaultChannel"].send(new ApmResultSet($metricName,new ApmResultEvent($flag,$objectName,detail, $timestamp)));endrule "ErrorsRule" no-loop enabled true when $t1: ApmSourceEvent($objectName: objectname,["applicationlication=HelloWord"] contains $objectName,$objectType: objecttype == "applicationlication", $timestamp:timestamp,$metricName:metricname == "errors") $flag : Integer() from accumulate( $t2: ApmSourceEvent( objectname == $objectName, objecttype == $objectType, metricname == $metricName, $metricValue : metricvalue, this before[0m, 9m59s] $t1 ), init(int result = 10030;), action( if ($metricValue <=1.0 && result <=10030) {result =10030;} else if ($metricValue >3.0){result =10032;} else if ($metricValue >1.0 && $metricValue <= 3.0 && result !=10032){result =10031 ;} ), result( new Integer( result ) ) ) then String info = "rulename:rules_errors,applicationlication" + $metricName; String detail = ""; if($flag == 10030){ detail = info + ";ruledetail:calls< 1.0 in last 10min;"; } if($flag == 10031){ detail = info + ";ruledetail: 1.0<errors< 3.0 in last 10min;"; } if($flag == 10032){ detail = info + ";ruledetail: errors>3.0 in last 10min;"; } channels["apmDefaultChannel"].send(new ApmResultSet($metricName,new ApmResultEvent($flag,$objectName,detail, $timestamp)));endrule "CallsRule" no-loop enabled true when $t1: ApmSourceEvent($objectName: objectname,["applicationlication=HelloWord"] contains $objectName,$objectType: objecttype == "applicationlication", $timestamp:timestamp,$metricName:metricname == "calls") $flag : Integer() from accumulate( $t2: ApmSourceEvent( objectname == $objectName, objecttype == $objectType, metricname == $metricName, $metricValue : metricvalue, this before[0m, 9m59s] $t1 ), init(int result = 10010;), action( if ($metricValue <=1.0 && result <=10010) {result =10010;} else if ($metricValue >3.0){result =10012;} else if ($metricValue >1.0 && $metricValue <= 3.0 && result !=10012){result =10011 ;} ), result( new Integer( result ) ) ) then String info = "rulename:rules_calls,applicationlication" + $metricName; String detail = ""; if($flag == 10010){ detail = info + ";ruledetail:calls< 1.0 in last 10min;"; } if($flag == 10011){ detail = info + ";ruledetail: 1.0<calls< 3.0 in last 10min;"; } if($flag == 10012){ detail = info + ";ruledetail: calls>3.0 in last 10min;"; } channels["apmDefaultChannel"].send(new ApmResultSet($metricName,new ApmResultEvent($flag,$objectName,detail, $timestamp)));end
0 0
- 基于Drools的CEP规则引擎实现
- CEP之于Drools规则引擎
- 基于 Jboss Drools 规则引擎开发框架
- 一个小学题目的解: 规则引擎Drools实现
- 使用 Drools 规则引擎实现业务逻辑
- 使用 Drools 规则引擎实现业务逻辑
- 使用 Drools 规则引擎实现业务逻辑
- 使用 Drools 规则引擎实现业务逻辑
- 使用 Drools 规则引擎实现业务逻辑
- 使用 Drools 规则引擎实现业务逻辑
- 使用 Drools 规则引擎实现业务逻辑
- 使用 Drools 规则引擎实现业务逻辑
- 使用 Drools 规则引擎实现业务逻辑
- 使用 Drools 规则引擎实现业务逻辑
- 使用 Drools 规则引擎实现业务逻辑
- 使用 Drools 规则引擎实现业务逻辑
- 使用 Drools 规则引擎实现业务逻辑
- 使用 Drools 规则引擎实现业务逻辑
- 阿里架构之旅(二)——Dubbo解析
- 自学Ajax
- Android 热补丁动态修复框架小结
- 百度万人协同规模下的代码管理架构演进
- ubuntu运行shell脚本
- 基于Drools的CEP规则引擎实现
- 抓包工具Fiddler的使用教程(十二)下:Fiddler抓取HTTPS
- WebUploader+SpringMVC实现文件上传功能
- RecycleView的Grid效果显示实现
- 算法1:寻找字符串数组中指定字符出现的字符串并排序
- XGBoost:多分类问题
- 欢迎使用CSDN-markdown编辑器
- zabbix 用SNMP监控交换机
- Linux常用命令(8)之文件搜索命令