SkyWalking监控告警

告警规则:SkyWalking 的发行版都会默认提供config/alarm-settings.yml文件,可以看源代码下




rules下配置各种告警规则

composite-rules下配置组合的规则

skywalking默认支持7中通知,web、grpc、微信、钉钉、飞书、华为weLink、slack

告警规则配置:

# Rule unique name, must be ended with `_rule`.

endpoint_percent_rule:

# Metrics value need to be long, double or int

  metrics-name: endpoint_percent

threshold: 75

op: <

# The length of time to evaluate the metrics

  period: 10

# How many times after the metrics match the condition, will trigger alarm

  count: 3

# How many times of checks, the alarm keeps silence after alarm triggered, default as same as period.

  silence-period: 10

only-as-condition: false

message: Successful rate of endpoint {name} is lower than 75%

Rule name:规则名称,也是在告警信息中显示的唯一名称。必须以_rule结尾,前缀可自定义

Metrics name:度量名称,取值为oal脚本中的度量名,目前只支持long、double和int类型。详见Official OAL script

Include names:该规则作用于哪些实体名称,比如服务名,终端名(可选,默认为全部)

Exclude names:该规则作不用于哪些实体名称,比如服务名,终端名(可选,默认为空)

Threshold:阈值

OP:操作符,目前支持>、<、=

Period:多久告警规则需要被核实一下。这是一个时间窗口,与后端部署环境时间相匹配

Count:在一个Period窗口中,如果values超过Threshold值(按op),达到Count值,需要发送警报

Silence period:在时间N中触发报警后,在TN -> TN + period这个阶段不告警。 默认情况下,它和Period一样,这意味着相同的告警(在同一个Metrics name拥有相同的Id)在同一个Period内只会触发一次

message:告警消息

告警插件:server-alarm-plugin

首先 看AlarmModuleProvider的prepare  ,会加载alarm-settings.yml,解释规则和通知勾子,组装成alarmRulesWatcher注册到MetricsNotify

警告消息体

public class AlarmMessage {

private int scopeId;        所有可用的 Scope 详见

private String scope;    目标 Scope 的实体名称

private String name;    Scope 实体的 ID

private String id0;

private String id1;

private String ruleName;        告警规则名称

private String alarmMessage;        告警规则消息

private List tags;                        tags

private long startTime;            开始时间

private transient int period;

private transient boolean onlyAsCondition;

}


如果想在skywalking中实现自己的通知勾子,需要实现AlarmCallback接口,实现doAlarm方法,参数就是AlarmMessage集合

在Rules中加入自己的配置


在NotifyHandler的init方法加入勾子

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。