skywalking告警UI界面有告警信息,webhook接口没有回调,400错误

400错误就是回调接口返回数据的属性对应不上

@PostMapping("/webhook")

public void webhook(@RequestBody List alarmMessageList)

自定义的实体类AlarmMessage有问题

只能去官网找了
告警实体类官网

java 复制代码
@Getter
@EqualsAndHashCode
@RequiredArgsConstructor
@NoArgsConstructor(force = true)
public class AlarmEntity {
    private final String scope;
    private final int scopeId;
    private final String name;
    private final String id0;
    private final String id1;
}

我使用的skywalking的版本是8.8.0

因为告警功能是基于这两个jar实现的

b站上,黑马的和图灵的讲师的实体类都不一样,所以不能直接抄,没有效果只能去分析skywalking的日志,看是不是发请求接口失败400了

完整代码如下:

实体类

java 复制代码
@Getter
@EqualsAndHashCode
@RequiredArgsConstructor
@NoArgsConstructor(force = true)
public class AlarmMessage {
    private final String scope;
    private final int scopeId;
    private final String name;
    private final String id0;
    private final String id1;
}

模拟超时的接口

java 复制代码
@RestController
public class AlarmController {
    @GetMapping("/timeout")
    public String timeout() throws InterruptedException {
        Thread.sleep(1500);
        return "timeout";
    }
}

告警回调接口

java 复制代码
@RestController
public class WebHooks {
    private List<AlarmMessage> lastList=new ArrayList<>();
    @PostMapping("/webhook")
    public void webhook(@RequestBody List<AlarmMessage> alarmMessageList){
        lastList = alarmMessageList;
    }
    @GetMapping("/show")
    public List<AlarmMessage> show(){
        return lastList;
    }
}

skywalking服务配置文件指定告警接口

多次请求http://localhost:8088/timeout

2分钟后一般会有告警信息出现

或者点击右上方的自动,再去请求接口,直到能出现告警

再去请求show接口,查看返回的数据

http://localhost:8088/show

有数据就是成功了,如果是空数组,就是webhook的接口没有回调成功,去看看skywalking的日志吧!!

相关推荐
图扑软件6 小时前
下篇・换墨|主题/多语言/移动端,一套组件全覆盖
前端·javascript·ui·性能优化·数据可视化
object not found2 天前
从 Page Design 到 System Design:我对 UI/UX 的一次认知变化
ui·ux
xy34532 天前
Axure9.0中继器遮罩实现方法
前端·ui·html·axure·原型·产品设计
晴天162 天前
Ant Design UI 库核心原理与应用
ui
玫瑰互动GEO2 天前
腾讯AnswerBit(GEO优化监测平台)技术拆解:UI自动化如何采集真实AI回答
大数据·人工智能·ui·ai·自动化·geo优化
摸鱼仙人~2 天前
Qwen-Code ACP与AG-UI协议深度解析:区别、场景与实战报文对比
ui
图扑软件3 天前
中篇・运笔|统一 DataModel 底座,HT UI 组件万物同源
javascript·低代码·ui·性能优化·数据可视化
l1m0_3 天前
智能电动自行车管理后台实战:AI生成页面与React组件化技巧
前端·react.js·ui·ai·设计
~远在太平洋~3 天前
06-鸿蒙系统 uitest UI 自动化指南
ui·自动化·harmonyos
兰亭妙微UI设计公司3 天前
兰亭妙微QT界面开发:设计系统侧边导航组件:告别混乱,实现高效协同
ui