# 飞书机器人异常告警 **Repository Path**: hong-yongtao/feishu-abnormal-alarm ## Basic Information - **Project Name**: 飞书机器人异常告警 - **Description**: 拦截异常,通知到飞书群进行告警通知,可以指定异常类型,设置白名单 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-05-29 - **Last Updated**: 2025-05-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 告警通知 ## 使用方法 ### 1.引入依赖 目前最新版本是:`1.0.3` ```xml cn.yaoud.salus salus-oms-alarm-spring-boot-starter 最新版本 ``` ### 2. 在群组中添加自定义机器人 方法参考:https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot?lang=zh-CN#399d949c ### 3.在nacos中配置通知机器人 1. 仅仅是想使用异常告警功能,只需配置一个机器人即可: ```yaml oms-alarm: feishu: custom: robot: robotList: - name: ALARM webhook: https://open.feishu.cn/open-apis/bot/v2/hook/5eb621b0-2918-4185-854d-417d2a3295f0 ``` 这种配置下,我们写的Controller接口如果发生异常会自动上报,除此之外,如果我们想主动上报异常,可以使用方法 `cn.yaoud.salus.oms.alarm.Alerter.report` 2. 如果想使用飞书通知功能,需为`cn.yaoud.salus.oms.alarm.Alerter`配置一个机器人: ```yaml oms-alarm: feishu: custom: robot: robotList: - name: ALARM webhook: https://open.feishu.cn/open-apis/bot/v2/hook/5eb621b0-2918-4185-854d-417d2a3295f0 - name: ALERTER webhook: https://open.feishu.cn/open-apis/bot/v2/hook/44b73c9b-9cf3-45f5-a874-d00e4642a323 ``` 3. 如果想要忽略告警指定类型异常,可配置 ```yaml oms-alarm: ignoreExceptions: - cn.yaoud.salus.common.core.exception.BusinessException ``` 4. 飞书机器人通知方式用法 查看单元测试类:cn.yaoud.salus.oms.alarm.feishu.bot.SendMsgTest 5. 忽略预料之中的异常 如果对于某种类型的异常希望可以不告警,除了可以直接通过第三点中提到的方式:`oms-alarm.ignoreExceptions`,忽略指定类型异常外(直接忽略告警指定类型可能过于武断),还可以抛出`cn.yaoud.salus.oms.alarm.exception.ExpectedBusinessException`,该类型继承自`cn.yaoud.salus.common.core.exception.BusinessException`。 `cn.yaoud.salus.oms.alarm.exception.ExpectedBusinessException`,这个类型的异常,默认情况下是不告警的,如果希望告警该类型,可以配置`oms-alarm.ignoreExpectedBusinessException=false`