open-falcon-archive / judge Goto Github PK
View Code? Open in Web Editor NEW告警判定组件
License: Apache License 2.0
告警判定组件
License: Apache License 2.0
比如如下场景
nginx监控插件采集了各种errorcode的数据,告警中带上具体的api的话能够快速定位问题,如果没给api和errorcode都要去配的话不现实,就算有精力配也没精力维护。
希望能够支持 tags: api=$(.),erorrcode=404 ,judge遇到这种$()包含的tag值,就将$()包含的内容解析为正则表达式,本例子将所有tagkey为api,errorcode=404的judgeItem进行阈值判断。
例如 tags: api=$(),erorrcode=404
api=/test/index.html,errorcode=404
api=/helloworld,errorcode=404
都会触发搞告警
tags: api=$(.),erorrcode=$(.)
api=/test/index.html,errorcode=500
api=/helloworld,errorcode=404
都会触发告警 。
告警信息中的tag就显示对应的api=/test/index.html,errorcode=500这种。
出现过一次,其中一台judge状态运行,healthcheck都是ok,api调用也正常,但是不从hbs获取策略。
问题发现过程:发现部分策略修改后,告警显示的内容是很久之前的。然后通过judge的api查看策略
curl http://judge-001ip:6081/strategy/hostname-eg/net.port.listen 发现策略是修改之前的旧策略
curl http://judge-002ip:6081/strategy/hostname-eg/net.port.listen 发现策略是修改之后的新策略
但是history发现历史数据让然发送到judge-001。所以告警的内容和触发条件是错误的。
重新启动judge-001后就正常了。
这个问题不好复现,但是真实存在且后果严重。目前没有定位到产生的原因。最好多开启debugHost配置项,然后多注意自己的judge的运行状态。
问题定位到了,g/rpc.go中的call方法死锁了。
this.rpcClient.Call(method, args, reply)并没有超时机制,该方法正在执行时网络意外中断将导致调用一直等待 。 rpc.go的call方法加锁无法释放,导致再也无法从hbs获取策略了。
Metric:df.bytes.free.percent Tags:fstype=NTFS,mount=C: all(#3): 5.14668<1 Note: Max:3, Current:1 Timestamp:2016-04-25 19:33:00
这个问题需要怎样排查
每次需要从SafeLinkedList中取出历史数据,进行判断。但是HistoryData()中当isEnough = false时,仍然去处理数据,而上层此时都直接return,并未对返回data做处理。为了避免多余的计算,其实isEnough = false的时候HistoryData()应该是直接return的?(虽然很少遇到不够的情况)
if judgeType == 'G' || judgeType == 'g' {
if size < limit {
// 有多少获取多少
limit = size
isEnough = false
}
vs = make([]*model.HistoryData, limit)
vs[0] = &model.HistoryData{Timestamp: firstItem.Timestamp, Value: firstItem.Value}
i := 1
currentElement := firstElement
for i < limit {
nextElement := currentElement.Next()
vs[i] = &model.HistoryData{
Timestamp: nextElement.Value.(*model.JudgeItem).Timestamp,
Value: nextElement.Value.(*model.JudgeItem).Value,
}
i++
currentElement = nextElement
}
} else {
…
}
如题。
另外,函数是否可以嵌套使用?
这个函数每次都需要得到一个报警判断的函数,是否可以在同步策略的时候,构造这个函数,不需要每次去解析,这样是否影响效率?
加入告警模板B继承于A,A模板上策略是 metric=errorcode.counts all(#1)>100
, 而B模板上策略是 metric=errorcode.counts tags: error_code=1003009 all(#1)>200
, 在judge代码中由于没有进行子策略覆盖父策略逻辑,导致A模板上的策略被触发产生告警,然而这并不是我所希望的。希望利用贪婪匹配优先匹配最合适的策略,然后再匹配其次的策略。
正在配置judge模块的时候碰到一个错误:
2015/12/04 17:37:56 strategy.go:25: [ERROR] Hbs.GetStrategies: invalid character 'H' looking for beginning of value
2015/12/04 17:37:56 strategy.go:59: [ERROR] Hbs.GetExpressions: invalid character 'H' looking for beginning of value
事实上falcon_portal库中expression表和strategy表都是空的,请问是哪一部分配置导致这个问题的呢?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.