日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

skywalking告警相关配置

發布時間:2024/4/15 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 skywalking告警相关配置 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

告警基本流程
????????skywalking發送告警的基本原理是每隔一段時間輪詢skywalking-collector收集到的鏈路追蹤的數據,再根據所配置的告警規則(如服務響應時間、服務響應時間百分比)等,如果達到閾值則發送響應的告警信息。發送告警信息是以線程池異步的方式調用webhook接口完成,(具體的webhook接口可以使用者自行定義),從而開發者可以在指定的webhook接口中自行編寫各種告警方式,釘釘告警、郵件告警等等。

告警相關配置
開啟skywalking相關告警配置,編輯 config/alarm-settings.yml,打開之后如下所示:rules即為需要配置的告警規則的列表;第一個規則‘endpoint_percent_rule’,是規則名,不能重復且必須以’_rule’為結尾;其中里面的屬性:
屬性?? ?含義
metrics-name?? ?指定的規則(與規則名不同,這里是對應的告警中的規則map,具體可查看https://github.com/apache/skywalking/blob/master/docs/en/setup/backend/backend-alarm.md#list-of-all-potential-metrics-name,其中一些常見的,endpoint_percent_rule——端點相應半分比告警,service_percent_rule——服務相應百分比告警)
threshold?? ?閾值,與metrics-name和下面的比較符號相匹配
op?? ?比較操作符,可以設定>,<,=,即如metrics-name: endpoint_percent, threshold: 75,op: < ,表示如果相應時長小于平均75%則發送告警
period?? ?多久檢查一次當前的指標數據是否符合告警規則
counts?? ?達到多少次告警后,發送告警消息
silence-period?? ?在多久之內,忽略相同的告警消息
message?? ?告警消息內容
include-names?? ?使用本規則告警的服務列表

rules:# Rule unique name, must be ended with `_rule`.endpoint_percent_rule:# Metrics value need to be long, double or intmetrics-name: endpoint_percentthreshold: 75op: <# The length of time to evaluate the metricsperiod: 10# How many times after the metrics match the condition, will trigger alarmcount: 3# How many times of checks, the alarm keeps silence after alarm triggered, default as same as period.silence-period: 10service_percent_rule:metrics-name: service_percent# [Optional] Default, match all services in this metricsinclude-names:- service_a- service_bthreshold: 85op: <period: 10count: 4webhooks:- http://127.0.0.1//alarm/test

webhook接口url的定義(地址自定義),除了規則制定之外,還有達到告警規則后,需要skywalking調用的webhook接口,如上所示的配置,一定要注意url的縮進,之前縮進兩個空格,一直沒生效。
????????配置完成之后,重啟skywalking生效;

告警webhook接口對接
????????編寫上述webhook對接的接口,http://127.0.0.1//alarm/test ,當前版本webhook接口調用的方式是post+requestbody,而body中的內容如下:

[{"scopeId":1, //指的是告警的范圍類型(源碼中有定義常量org.apache.skywalking.oap.server.core.source.DefaultScopeDefine)"name":"gateway", //告警服務名稱"id0":3, //與服務名稱一一匹配"id1":0, //暫時未做使用 "alarmMessage":"Response time of service gateway is more than 1000ms in 3 minutes of last 10 minutes.","startTime":1569552742633 //告警發起時間戳},{"scopeId":1,"name":"en-exercise","id0":2,"id1":0,"alarmMessage":"Response time of service en-exercise is more than 1000ms in 3 minutes of last 10 minutes.","startTime":1569552742633} ]

于是定義的接口如下:

@RequestMapping("/alarm") @RestController public class AlarmController {@AutowiredAlarmService alarmService;@RequestMapping(value = "/test",method = RequestMethod.POST)public void alarm(@RequestBody List<AlarmMessageDto> alarmMessageList){System.out.println(alarmMessageList.toString());//具體處理告警信息alarmService.doAlarm(alarmMessageList);} } //實體類 @Data public class AlarmMessageDto {private int scopeId;private String name;private int id0;private int id1;private String alarmMessage;private long startTime; }

?

總結

以上是生活随笔為你收集整理的skywalking告警相关配置的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。