• 告警规则主要有以下几点

    Webhook

    SkyWalking 的告警 Webhook 要求对等方是一个 Web 容器. 告警的消息会通过 HTTP 请求进行发送, 请求方法为 POST, Content-Type 为 application/json, JSON 格式基于 List<org.apache.skywalking.oap.server.core.alarm.AlarmMessage, 包含以下信息.

    [{
    "scopeId": 1,
    "name": "serviceA",
    "id0": 12,
    "id1": 0,
    "alarmMessage": "alarmMessage xxxx",
    "startTime": 1560524171000
    }, {
    "scopeId": 1,
    "name": "serviceB",
    "id0": 23,
    "id1": 0,
    "alarmMessage": "alarmMessage yyy",
    "startTime": 1560524171000
    }]

    代码实战

    @Data
    public class SwAlarmVO {
    private int scopeId;
    private String name;
    private int id0;
    private int id1;
    private String alarmMessage;
    private long startTime;
    }
    @RestController
    @RequestMapping("sw")
    @Log4j2
    public class AlarmController {
    @PostMapping("/alarm")
    public void alarm(@RequestBody List<SwAlarmVO> alarmList){
    log.info("skywalking alarm message:{}",alarmList);
    //todo doalarm
    }
    }

    [SwAlarmVO(scopeId = 2, name = dubbo - consumer - pid: 13812 @ jianzhang11, id0 = 28, id1 = 0, alarmMessage = Response time of service instance dubbo - consumer - pid: 13812 @ jianzhang11 is more than 1000ms in 2 minutes of last 10 minutes, startTime = 1573122018755), SwAlarmVO(scopeId = 2, name = dubbo - provider2 - pid: 14108 @ jianzhang11, id0 = 25, id1 = 0, alarmMessage = Response time of service instance dubbo - provider2 - pid: 14108 @ jianzhang11 is more than 1000ms in 2 minutes of last 10 minutes, startTime = 1573122018755)]
    说明webhook能正常接收到sw的告警信息,后续的消息通知直接定制开发即可。基于SkyWalking的分布式跟踪系统 - 异常告警-LMLPHP

     基于SkyWalking的分布式跟踪系统 - 异常告警-LMLPHP相关阅读



    本文分享自微信公众号 - JAVA日知录(javadaily)。
    如有侵权,请联系 [email protected] 删除。
    本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。

    09-13 10:57