实现skywalking 实现钉钉告警

告警指标

  官网告警规则示例

  https://github.com/apache/skywalking/blob/master/docs/en/setup/backend/backend-alarm.md

 

告警指标示例

  service_resp_time   #服务的响应时间

  service_sla         #服务的http请求成功率SLA,比如99%等。

  service_cpm        #表示每分钟的吞吐量. 

  service_apdex :     #应用性能指数是0.8是0.x

  service_percentile:   #指定最近多少数据范围内的响应时间百分比,即p99, p95, p90, p75, p50在内的数据统计结果

  endpoint_relation_cpm      #端点的每分钟的吞吐量

  endpoint_relation_resp_time   #端点的响应时间

  endpoint_relation_sla     #端点的http请求成功率SLA,比如99%等。

  endpoint_relation_percentile    #端点的最近多少数据范围内的响应时间百分比,即p99、p95、p90、p75、p50在内的数据统计结果

 

更多指标与规则:

  https://github.com/apache/skywalking/blob/master/docs/en/setup/backend/backend-alarm.md#list-of-all-%20potential-metrics-name

 

  skywalking本地查询语句配置文件路径

root@skywalking:/usr/local/apache-skywalking-apm-bin-es7# ll config/oal/core.oal

 

  告警规则文件

root@skywalking:/usr/local/apache-skywalking-apm-bin-es7# ll config/alarm-settings.yml 
-rw-rw-r-- 1 1001 1002 3298 Jun  7  2021 config/alarm-settings.yml

 

 

规则示例

  告警规则文件

root@skywalking:/usr/local/apache-skywalking-apm-bin-es7/config# cat alarm-settings.yml
# Sample alarm rules.
rules:
  # Rule unique name, must be ended with `_rule`.
  service_resp_time_rule:    #规则名称,名称的结尾必须是_rule
    metrics-name: service_resp_time   #指标名称,与config/oal/core.oal下的指标语句名称相匹配
    op: ">"    #操作符,>, >=, <, <=, ==
    threshold: 1000   #指标阈值
    period: 10      #评估指标的间隔周期,单位分钟。
    count: 3       #匹配成功多少次就会触发告警
    silence-period: 5     #触发告警后的静默(延迟)时间,建议时间不要设置太长,单位分钟。
    message: Response time of service {name} is more than 1000ms in 3 minutes of last 10 minutes.    #告警内容信息

 

 

配置告警

  配置skywalking告警模版,设置为钉钉告警

  定义每分钟的吞吐量大于1的话就会触发告警。

root@skywalking:/usr/local/apache-skywalking-apm-bin-es7/config# vim alarm-settings.yml
rules:
  # Rule unique name, must be ended with `_rule`.
  service_resp_time_rule:
    metrics-name: service_cpm
    op: ">"
    threshold: 5
    period: 1
    count: 1
    silence-period: 1
    message: Response time of service {name} is more than 5ms in 1 minutes.

dingtalkHooks:
  textTemplate: |-
    {
      "msgtype": "text",
      "text": {
        "content": "Apache skywalking Alarm \n %s."
      }
    }
  webhooks:
    - url: https://oapi.dingtalk.com/robot/send?access_token=6755dc6d17a9a5b5597f60628d65e2c4d454be1325ea3bb68673ec50816
1a373

 

 

 

  重启skywalking

 

  配置钉钉机器人

 

 

  验证:

 

  验证skywalking server端触发告警

 

posted @ 2023-03-09 16:32  PunchLinux  阅读(539)  评论(0编辑  收藏  举报