Comments (3)
不好意思,没看仔细有2个Function,
@OverRide
public void run(SourceContext sourceContext) throws Exception {
while (isRunning) {
try {
logger.info("Http to get alarm rules from " + ruleUrl);
// String content = HttpUtil.doGet(ruleUrl);
String content = HttpUtil.doGetMock(ruleUrl);
if (content == null) {
logger.error("Failed to get alarm rules from url {}", ruleUrl);
return;
}
sourceContext.collect(content);
Thread.sleep(60000);
} catch (Exception ex) {
logger.error("Get rule source exception: " + ex.toString());
}
}
}
这里是不是只能执行一条规则?
from eagle.
我看代码里规则是mock的?
private static String mockRules = "[{\n" +
"\t"id": 123,\n" +
"\t"name": "eagle_log_rule_1",\n" +
"\t"appId": "059b0847-4fda-487a-ab85-7a5e625a8bd1",\n" +
"\t"type": "logrules",\n" +
"\t"script": "package logrules\n\nimport com.alarm.eagle.util.DateUtil;\nimport com.alarm.eagle.log.LogEntry;\nimport org.slf4j.Logger;\nimport com.alarm.eagle.util.Md5Util;\nimport com.alarm.eagle.util.RegexUtil\nimport java.util.Date;\n\nglobal Logger LOG;\n\nrule \"eagle_log_rule_1\"\nno-loop true\nsalience 100\nwhen\n $log : LogEntry( index == \"eagle_log_1\", $msg : message)\nthen\n LOG.debug(\"receive eagle_log_1 log, id:[{}]\", $log.getId());\n String type = $log.getType();\n if (\"opm\".equals(type)){\n String logTime = RegexUtil.extractString(\"(\\\\d{4}-\\\\d{2}-\\\\d{2} \\\\d{2}:\\\\d{2}:\\\\d{2}.\\\\d{3})\", $msg);\n if(logTime == null){\n LOG.warn(\"invalid date or time, log: {}\", $msg);\n return;\n }\n Date date = DateUtil.convertFromString(\"yyyy-MM-dd HH:mm:ss.SSS\", logTime);\n $log.setTimestamp(date != null ? date : $log.getAtTimestamp());\n if ($msg.contains(\"EventTracking\")){\n String tracking = RegexUtil.extractString(\"(EventTracking.+)\", $msg);\n if (tracking != null){\n String[] tracks = tracking.split(\"\\\\|\");\n $log.addField(\"EventType\",tracks[0]);\n $log.addField(\"LogType\",tracks[1]);\n $log.addField(\"LogId\",tracks[2]);\n $log.addField(\"UserId\",tracks[3]);\n $log.addField(\"LogTime\",tracks[4]);\n }\n }\n } else if (\"offermanager\".equals(type)){\n String logTime = RegexUtil.extractString(\"(\\\\d{4}-\\\\d{2}-\\\\d{2} \\\\d{2}:\\\\d{2}:\\\\d{2},\\\\d{3})\", $msg);\n if(logTime == null){\n LOG.warn(\"invalid date or time, log: {}\", $msg);\n return;\n }\n Date date = DateUtil.convertFromString(\"yyyy-MM-dd HH:mm:ss,SSS\", logTime);\n $log.setTimestamp(date != null ? date : $log.getAtTimestamp());\n } else {\n return;\n }\n\n long delayTime = (System.currentTimeMillis() - $log.getTimestamp().getTime())/1000;\n if (delayTime > 5243600 || delayTime < -5243600) {\n LOG.warn(\"Too early or too late log, ignore it, delay:{}, log:{}\", delayTime, $log.getTimestamp().getTime());\n return;\n }\n $log.dealDone();\n LOG.debug(\"out -----eagle_log_1------\");\nend",\n" +
"\t"version": "20190729",\n" +
"\t"state": 1,\n" +
"\t"updateTime": 1564475611452\n" +
"}, {\n" +
"\t"id": 456,\n" +
"\t"name": "eagle_log_rule_2",\n" +
"\t"appId": "2a2df323-d2ea-45ca-bf7e-6d2afa125688",\n" +
"\t"type": "logrules",\n" +
"\t"script": "package logrules\n\nimport org.slf4j.Logger;\nimport java.util.Date;\nimport java.util.Locale;\nimport com.alarm.eagle.log.LogEntry;\nimport com.alarm.eagle.util.RegexUtil;\nimport com.alarm.eagle.util.DateUtil\nimport java.time.LocalDateTime;\n\nglobal Logger LOG;\n\nrule \"eagle_log_rule_2\"\n\tno-loop true\n\tsalience 100\n when\n $log : LogEntry(index == \"eagle_log_2\", $msg : message)\n then\n LOG.debug(\"receive eagle_log_2 log, id:[{}]\", $log.getId());\n String logTime = RegexUtil.extractString(\"(\\\\d{4}-\\\\d{2}-\\\\d{2} \\\\d{2}:\\\\d{2}:\\\\d{2}.\\\\d{3})\", $msg);\n if(logTime == null){\n LOG.warn(\"invalid date or time, log: {}\", $msg);\n return;\n }\n Date date = DateUtil.convertFromString(\"yyyy-MM-dd HH:mm:ss,SSS\", logTime);\n $log.setTimestamp(date!=null? date:$log.getAtTimestamp());\n\n $log.dealDone();\n LOG.debug(\"out ----- eagle_log_2 log-----\");\nend",\n" +
"\t"version": "20190826",\n" +
"\t"state": 1,\n" +
"\t"updateTime": 1567078969483\n" +
"}]";
我就想知道alarm/rules的格式是什么?
from eagle.
这个flink的项目解决的问题是:一种数据用一种drools规则去处理。
数据库里存的和mock的是一样的,具体的drools规则是script里的内容。
from eagle.
Related Issues (9)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eagle.