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的日志吧!!

相关推荐
YJlio28 分钟前
OpenClaw v2026.5.26-beta.1 / beta.2 预发布解读:Gateway 加速、transcript 路径统一、多通道修复、语音增强与安装更新链路加固
人工智能·windows·python·ui·缓存·gateway·outlook
Roc-xb17 小时前
hermes-web-ui安装教程
前端·ui·hermes-web-ui
xiami_world19 小时前
从prompt到产品:AI 生成 UI 的三条技术路径对比与工程实践
人工智能·ui·ai·prompt·aigc·ai编程
ZC跨境爬虫1 天前
跟着 MDN 学CSS day_50:(传统布局方法与网格系统)
前端·css·ui·tensorflow·媒体
文创工作室1 天前
Adobe Photoshop 2024 多国语言版本
ui·adobe·photoshop
summerkissyou19872 天前
Android-UI-获取屏幕尺寸的方法
android·ui
汉得数字平台2 天前
让提示更智能,弹窗更灵动:Choerodon UI 浮层交互体验优化
ui·前端组件
小书房2 天前
Android UI为什么由XML转向Compose
xml·ui·compose·声明式ui
ZC跨境爬虫2 天前
跟着 MDN 学CSS day_45:媒体查询入门指南——从语法到移动优先实践
前端·css·ui·html·tensorflow·媒体
xiami_world2 天前
Multi-Agent架构选型实战:5个主流平台工具深度横评
人工智能·ui·ai·agi·用户界面