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

相关推荐
左手厨刀右手茼蒿18 小时前
Flutter for OpenHarmony 实战:Barcode — 纯 Dart 条形码与二维码生成全指南
android·flutter·ui·华为·harmonyos
njsgcs20 小时前
windows ui窗口post 我wsl开放的flask llm端点
windows·ui·flask·post
中国胖子风清扬21 小时前
Rust 桌面应用开发的现代化 UI 组件库
java·后端·spring·ui·rust·kafka·web application
左手厨刀右手茼蒿1 天前
Flutter for OpenHarmony 实战:equatable 插件简化值相等性的终极方案
android·flutter·ui·harmonyos
草莓熊Lotso1 天前
Qt 对话框全家桶实战:模态 / 非模态 + 5 大内置对话框全攻略
运维·c语言·开发语言·c++·人工智能·qt·ui
金融RPA机器人丨实在智能1 天前
从 UI 自动化到 Agentic RPA:深度解析实在智能 TARS 大模型驱动的自动化架构演进
人工智能·ui·ai·自动化·rpa
左手厨刀右手茼蒿1 天前
Flutter for OpenHarmony 实战:battery_plus 实时电力监控与低功耗逻辑
android·flutter·ui·harmonyos·sentry
大黄说说2 天前
从意图到界面:AI 驱动的 JSON 中间表示如何重塑现代 UI 构建范式
人工智能·ui·json
左手厨刀右手茼蒿3 天前
Flutter for OpenHarmony:UI 细节微调与 HarmonyOS 特有手势适配指南
flutter·ui·harmonyos
左手厨刀右手茼蒿3 天前
Flutter for OpenHarmony 实战:Sentry 全链路监控与线上崩溃治理
android·flutter·ui·harmonyos·sentry