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

相关推荐
咖啡の猫4 小时前
PC 端常用 UI 组件库
ui
我的xiaodoujiao6 小时前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 25--数据驱动--参数化处理 Excel 文件 2
前端·python·学习·测试工具·ui·pytest
top_designer10 小时前
Firefly 样式参考:AI 驱动的 UI 资产“无限”生成
前端·人工智能·ui·aigc·ux·设计师
Dr.勿忘2 天前
Unity一分钟思路---UI任务条:宝箱位置如何准确卡在百分比位置上
ui·unity·游戏程序·屏幕适配
覆东流2 天前
Photoshop图形工具组与图层样式
ui·photoshop
集成显卡2 天前
AI取名大师 | uni-app + Wot UI 跟随设备自动切换明暗主题
人工智能·ui·uni-app·外观配色
测试19983 天前
如何用Appium实现移动端UI自动化测试?
自动化测试·软件测试·python·测试工具·ui·职场和发展·appium
jf加菲猫3 天前
第2章 Hello World
开发语言·c++·qt·ui
百***06943 天前
Skywalking介绍,Skywalking 9.4 安装,SpringBoot集成Skywalking
spring boot·后端·skywalking
将编程培养成爱好3 天前
C++ 设计模式《外卖骑手状态系统》
c++·ui·设计模式·状态模式