ThingsBoard - 设备告警推送三方系统、Kafka、邮箱(四)

257 阅读2分钟

一、设备告警规则配置

image.png image.png image.png image.png image.png image.png image.png

二、如何将报警数据推送到自己的业务平台

方式一:通过消息通知配置 image.png image.png image.png image.png image.png image.png 方式二:通过规则链 http 推送配置 (存在授权问题) image.png image.png image.png image.png image.png image.png image.png

{
    "id": {
        "entityType": "ALARM",
        "id": "efd35f24-354b-4f90-a0a9-8541b14d9d3b"
    },
    "createdTime": 1732976870133,
    "tenantId": {
        "entityType": "TENANT",
        "id": "6cbffce0-adfc-11ef-8488-818762120fc7"
    },
    "customerId": null,
    "type": "温度过高报警",
    "originator": {
        "entityType": "DEVICE",
        "id": "70ea0c90-aec2-11ef-8488-818762120fc7"
    },
    "severity": "CRITICAL",
    "acknowledged": false,
    "cleared": true,
    "assigneeId": null,
    "startTs": 1732976870105,
    "endTs": 1732976870105,
    "ackTs": 0,
    "clearTs": 1732976871498,
    "assignTs": 0,
    "propagate": false,
    "propagateToOwner": false,
    "propagateToTenant": false,
    "propagateRelationTypes": [],
    "originatorName": "温湿度设备",
    "originatorLabel": "设备",
    "assignee": null,
    "name": "温度过高报警",
    "status": "CLEARED_UNACK",
    "details": {
        "data": "当前温度50,消除温度过高报警。",
        "entityKeys": "temperature",
        "dashboardId": "6ce5d460-adfc-11ef-8488-818762120fc7"
    }
}
{
    "id": {
        "entityType": "ALARM",
        "id": "efd35f24-354b-4f90-a0a9-8541b14d9d3b"
    },
    "createdTime": 1732976870133,
    "tenantId": {
        "entityType": "TENANT",
        "id": "6cbffce0-adfc-11ef-8488-818762120fc7"
    },
    "customerId": null,
    "type": "温度过高报警",
    "originator": {
        "entityType": "DEVICE",
        "id": "70ea0c90-aec2-11ef-8488-818762120fc7"
    },
    "severity": "CRITICAL",
    "acknowledged": false,
    "cleared": false,
    "assigneeId": null,
    "startTs": 1732976870105,
    "endTs": 1732976870105,
    "ackTs": 0,
    "clearTs": 0,
    "assignTs": 0,
    "propagate": false,
    "propagateToOwner": false,
    "propagateToTenant": false,
    "propagateRelationTypes": [],
    "originatorName": "温湿度设备",
    "originatorLabel": "设备",
    "assignee": null,
    "name": "温度过高报警",
    "status": "ACTIVE_UNACK",
    "details": {
        "data": "当前温度111,触发温度过高报警。",
        "entityKeys": "temperature",
        "dashboardId": "6ce5d460-adfc-11ef-8488-818762120fc7"
    }
}

备注:tb 报警不会返回entityKeys,修改源码后返回的

Set<AlarmConditionFilterKey> entityKeys = ruleState.getEntityKeys();
if (CollectionsUtil.isNotEmpty(entityKeys)){
    newDetails.put("entityKeys", entityKeys.stream().map(AlarmConditionFilterKey::getKey).collect(Collectors.joining(",")));
}

image.png

方式三:通过规则链kafka配置 image.png image.png image.png image.png 三、如何将报警数据推送邮件服务器 如果配置温度以及湿度报警,通过以上方式温度湿度都会推送报警,如果温度告警推送邮箱通知,湿度不需要推送的话该如何? image.png image.png image.png image.png image.png image.png image.png image.png