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

相关推荐
界面开发小八哥3 小时前
界面控件DevExpress XAF v26.1新版亮点——Blazor UI功能增强(二)
ui·界面控件·blazor·devexpress·ui开发
Oll Correct4 小时前
Adobe illustrator 案例四:吃豆人 (Pac-Man)图标绘制
笔记·ui·adobe·illustrator
阿图灵18 小时前
Agentic AI 架构入门(九):Agent 通信协议全景——ACP/A2A/AG-UI/MCP
人工智能·ui·架构·ai agent·智能体·mcp·agentic ai
AI分享猿1 天前
UI设计Prompt系列(十二):设计系统入门——把视觉语言沉淀为可复用规范
ui·prompt
l1m0_1 天前
告别反复修改Prompt:AI生成React应用并落地开发的实战复盘
前端·react.js·ui·ai·设计
大千UI工场1 天前
时序数据库对数字孪生的作用
数据库·ui·时序数据库·前端开发·b端管理系统
UnicornIT1 天前
【HarmonyOS】时间管理类APP:做成“自适应“
ui·华为·harmonyos·鸿蒙
AI分享猿2 天前
UI设计Prompt系列(六):原型验证提速——用设计Prompt跳过反复改稿
ui·prompt
兰亭妙微UI设计公司2 天前
兰亭妙微UIUE设计公司:海量股票数据如何清晰呈现?百度金融从搜索页到官网的系统化 UI 升级复盘
ui·百度·金融