作者: 浏览量:234 更新时间: 2020.06.23
1.云端:提供云端的SDK API给到ISV用于管理态的应用的远端告警API调用。
2.同步:平台通过云->边同步机制,把云端的应用的告警规则和数据同步到边缘集群。
3.边侧:提供边侧的SDK API给到ISV用于运行态告警规则的校验和信息获取。
告警开放服务是应用服务平台告警功能的API版本,除继承原有告警功能外,还扩展支持告警边缘端部署运行,不同类型设备联合告警,时间窗口延迟触发告警等功能。
开始接入告警开放服务前,需要入驻应用服务平台:
AppKey:API访问凭证编号,用于验证API接入API Gateway合法性;
AppSecret:与AppKey配套的验证秘钥,请妥善保管并确保不在网络中传输。
所有的告警服务API均定义在IoT API网关上,AppKey和AppSecert是API网关的凭证访问,用户在接入时,可集成iot-api-gateway-client sdk,并配置AppKey和AppSecert。
在应用服务平台创建项目后,可进入项目,在项目开发态里获取到AppKey和AppSecert。如下图所示:
| 参数 | 类型 | 备注 |
|---|---|---|
| code | Integer | 业务返回码 |
| message | String | 英文描述信息 |
| localMessage | String | 中文描述信息 |
| data | null(无数据) | 这时没有data字段,表示接口的返回值中没有结果; |
| JSONObject(对象类型) | 表示结果是一系列值,值的类型要根据接口而定; |
|
| JSONArray(数组类型) | 表示结果是一系列值,值的类型要根据接口而定; | |
| Integer/Long/Byte/Double等 (值类型) |
表示结果是一系列值,值的类型要根据接口而定; |
| 错误码 | 错误信息 | 业务结果描述 |
|---|---|---|
| 200 | success. | 成功 |
| 500 | service error. | 服务端错误 |
| 10374 | There are rules with the same content. | 该规则触发源设置的规则数量已经超过上限。 |
| 28403 | The project not exist. | 该项目不存在。 |
| 28405 | Param illegal. | 参数非法。 |
| 28420 | No access to alarm rule. | 无权访问该告警规则。 |
| 28457 | Alarm status illegal. | 规则状态不合法。 |
| 29262 | Alarm lowSceneConfig error. | 限值告警下限配置错误。 |
| 29263 | InstanceId param error. | 边缘实例id错误。 |
| 29264 | InstanceId not exist. | 边缘实例id不存在。 |
| 29267 | Deploy alarm instance error. | 部署告警边缘实例失败。 |
| 29268 | Alarm device not bind. | 配置告警的设备未绑定到项目。 |
| 29269 | Only cloud support multiDevice. | 只有云端告警支持多设备。 |
路径:/alarm/rule/addorupdate
版本:1.0.0
| 参数名 | 字段类型 | 是否必填 | 描述 |
|---|---|---|---|
| alarmName | String | 必填 | 告警规则名称 |
| alarmLevel | Integer | 必填 | 告警等级,0严重,1高,2中,3低 |
| auxiliaryLevel | Integer | 非必填 | 辅助等级,0~999,客户自定义 |
| alarmContent | String | 必填 | 告警内容 |
| productKey | String | 必填 | 设备PK |
| sceneConfig | String | 必填 | 阈值告警规则配置(限值告警高限值配置) |
| receivers | JSONArray | 非必填 | 告警接收者 |
| -> type | String | 非必填 | 类型,EMAIL邮件,receivers存在时必填 |
| String | 非必填 | 邮箱地址 | |
| alarmType | Integer | 必填 | 告警类型,1运行告警,2故障告警 |
| alarmMode | Integer | 必填 | 告警模式,1阈值告警,2限值告警 |
| timeWindow | Integer | 非必填 | 时间窗口,持续一段时间后触发,单位:秒,边缘告警不填 |
| runEnv | String | 必填 | 运行环境,cloud云端,edge边缘端 |
| alarmRuleId | String | 非必填 | 告警规则id,更新时必填 |
| lowSceneConfig | String | 非必填 | 限值告警的低限值规则配置,限制告警必填 |
| 参数名 | 字段描述 |
|---|---|
| sceneConfig | 见附录1 |
| lowSceneConfig | 见附录1 |
| 参数名 | 字段类型 | 描述 |
|---|---|---|
| 新增或更新的告警记录id |
{"alarmName": "新增告警规则","alarmLevel": 0,"auxiliaryLevel": 10,"alarmContent": "设备产生告警","productKey": "a1gEQeIkPn5","sceneConfig": "{/* 见附录1 */}","receivers": [{"type": "EMAIL","email": "test@163.com"}]"alarmType": 1,"alarmMode": 1,"timeWindow": 300,"runEnv": "cloud","multiDevice": 0}
返回成功:{"code": 200,"message": "success","data": "8e2e8d41f4604878b413fc588333f068"}返回失败:{"code": 28403,"message": "The project not exist","localizedMsg": "该项目不存在"}
路径:/alarm/rule/delete
版本:1.0.0
| 参数名 | 字段类型 | 是否必填 | 描述 |
|---|---|---|---|
| alarmRuleIds | JSONArray |
必填 | 告警规则id的集合 |
| clusterId | String | 非必填 | 集群id,告警运行在边缘端时必填 |
| 参数名 | 字段描述 |
|---|---|
| clusterId | 集群ID |
| 数组子参数 | ||
|---|---|---|
| 删除失败的告警规则id |
| 数组子参数 | ||
|---|---|---|
| 删除失败的告警规则id |
批量删除边缘端告警。
{["8e2e8d41f4604878b413fc588333f068", "df152383d40842b0814346cc88cfd1b4"],"pVxFeNmZ8axogEnWCD9E"}
返回成功:{"code": 200,"message": "success","data": ["df152383d40842b0814346cc88cfd1b4"]}返回失败:{"code": 28420,"message": "No access to alarm rule","localizedMsg": "无权访问该告警规则"}
分页查询告警规则列表,按创建日期倒序。
路径:/alarm/rule/query
版本:1.0.0
| 参数名 | 字段类型 | 是否必填 | 描述 |
|---|---|---|---|
| nameLike | String | 非必填 | 告警规则名称,模糊匹配 |
| alarmLevel | Integer | 非必填 | 告警等级,0严重,1高,2中,3低 |
| status | Integer | 非必填 | 启用状态,1启用,0停止 |
| alarmType | Integer | 非必填 | 告警类型,1运行告警,2故障告警 |
| alarmMode | Integer | 非必填 | 告警模式,1阈值告警,2限值告警,默认阈值告警 |
| runEnv | String | 非必填 | 运行环境,cloud云端,edge边缘端 |
| pageNo | Integer | 非必填 | 当前页码,默认1 |
| pageSize | Integer | 非必填 | 每页条数,默认20 |
| 参数名 | 字段描述 |
|---|---|
| 无 |
| 参数名 | 字段类型 | 描述 |
|---|---|---|
| total | Integer | 总条数 |
| pageNo | Integer | 当前页码 |
| pageSize | Integer | 每页条数 |
| data | Integer | 告警规则列表 |
| -> alarmRuleId | String | 告警规则id |
| -> alarmName | String | 告警规则名称 |
| -> status | Integer | 启用状态,1启用,0停止 |
| -> alarmLevel | Integer | 告警等级,0严重,1高,2中,3低 |
| -> auxiliaryLevel | Integer | 辅助等级,0~999,用户自定义 |
| -> content | String | 告警内容 |
| -> productKey | String | 设备PK |
| -> alarmType | Integer | 告警类型,1运行告警,2故障告警 |
| -> runEnv | String | 运行环境,cloud云端,edge边缘端 |
| -> multiDevice | Integer | 是否多设备,0单设备,1多设备 |
| -> alarmMode | Integer | 告警模式,1阈值告警,2限值告警 |
| -> timeWindow | Integer | 时间窗口,告警满足条件持续一段时间后触发,单位:秒 |
筛选条件全填,查询第1页10条告警规则。
{"nameLike": "告警","alarmLevel": 0,"alarmType": 1,"status": 1,"alarmMode": "2","runEnv": "edge","pageNo": 1,"pageSize": 10}
返回成功:{"code": 200,"message": "success","data": {"total": 100,"pageNo": 1,"pageSize": 10,"data": [{"alarmRuleId": "df152383d40842b0814346cc88cfd1b4","alarmName": "设备告警","status": 1,"alarmLevel": 0,"auxiliaryLevel": 5,"content": "设备电压超标","productKey": "a1gEQeIkPn5","alarmType": 1,"runEnv": "edge","multiDevice": 0,"alarmMode": 2,"timeWindow": 600}]}}返回失败:{"code": 28403,"message": "The project not exist","localizedMsg": "该项目不存在"}
根据告警规则id查询单个告警规则的详情。
路径:/alarm/rule/detail/get
版本:1.0.0
| 参数名 | 字段类型 | 是否必填 | 描述 |
|---|---|---|---|
| alarmRuleId | String | 必填 | 告警规则id |
| 参数名 | 字段描述 |
|---|---|
| 无 |
| 参数名 | 字段类型 | 描述 |
|---|---|---|
| alarmRuleId | String | 告警规则id |
| alarmName | String | 告警规则名称 |
| status | Integer | 启用状态,1启用,0停止 |
| alarmLevel | Integer | 告警等级,0严重,1高,2中,3低 |
| auxiliaryLevel | Integer | 辅助等级,0~999,用户自定义 |
| content | String | 告警内容 |
| productKey | String | 设备PK |
| sceneConfig | String | 阈值告警规则配置(限值告警高限值配置) |
| receivers | JSONArray | 告警接收者 |
| -> type | String | 类型,EMAIL邮件 |
| String | 邮箱地址 | |
| alarmType | Integer | 告警类型,1运行告警,2故障告警 |
| lowSceneConfig | String | 限值告警的低限值规则配置 |
| runEnv | String | 运行环境,cloud云端,edge边缘端 |
| multiDevice | Integer | 是否多设备,0单设备,1多设备 |
| alarmMode | Integer | 告警模式,1阈值告警,2限值告警 |
| timeWindow | Integer | 时间窗口,告警满足条件持续一段时间后触发,单位:秒 |
查询单个告警规则的详细信息。
{"alarmRuleId": "df152383d40842b0814346cc88cfd1b4"}
返回成功:{"code": 200,"message": "success","data": {"alarmRuleId": "df152383d40842b0814346cc88cfd1b4","alarmName": "设备告警","status": 1,"alarmLevel": 0,"auxiliaryLevel": 5,"content": "设备电压超标","productKey": "a1gEQeIkPn5","sceneConfig": "{}","receivers": [{"type": "EMAIL","email": "test@163.com"}],"alarmType": 1,"lowSceneConfig": "{}","runEnv": "edge","multiDevice": 0,"alarmMode": 2,"timeWindow": 600}}返回失败:{"code": 28403,"message": "The project not exist","localizedMsg": "该项目不存在"}
批量启动、停止告警规则。
路径:/alarm/rule/status/update
版本:1.0.0
| 参数名 | 字段类型 | 是否必填 | 描述 |
|---|---|---|---|
| alarmRuleIds | JSONArray |
必填 | 告警规则id |
| operType | Integer | 必填 | 操作类型,1启动,0停止 |
| clusterId | String | 非必填 | 集群id,告警运行在边缘端时必填 |
| 参数名 | 字段描述 |
|---|---|
| 无 |
| 参数名 | 字段类型 | 描述 |
|---|---|---|
| 启停失败的告警规则id |
批量停止告警规则。
{["8e2e8d41f4604878b413fc588333f068", "df152383d40842b0814346cc88cfd1b4"],"operType": 0,"pVxFeNmZ8axogEnWCD9E"}
返回成功:{"code": 200,"message": "success","data": ["df152383d40842b0814346cc88cfd1b4"]}返回失败:{"code": 28420,"message": "No access to alarm rule","localizedMsg": "无权访问该告警规则"}
批量确认告警记录。
路径:/alarm/record/confirm
版本:1.0.0
| 参数名 | 字段类型 | 是否必填 | 描述 |
|---|---|---|---|
| alarmRecordIds | JSONArray |
必填 | 告警记录id |
| confirm | Integer | 必填 | 确认状态,0未确认,1已确认 |
| 参数名 | 字段描述 |
|---|---|
| 无 |
| 参数名 | 字段类型 | 描述 |
|---|---|---|
| 修改确认状态失败的告警记录id |
批量确认告警记录。
{"alarmRecordIds": [1000000001, 1000000002],"confirm": 1}
返回成功:{"code": 200,"message": "success","data": [1000000002]}返回失败:{"code": 28403,"message": "The project not exist","localizedMsg": "该项目不存在"}
地产平台通过封装LP云边同步能力,对外开放如下API:
0、获取边缘集群列表
1、数据同步预检查
2、触发数据同步
3、数据同步结果查询
分页参数会出现在请求参数和返回结果中,用于下文中API调用参照。
所有的分页接口除特殊说明外,都遵循下面的约束:
| 参数 | 类型 | 备注 |
|---|---|---|
| pageNo | Integer | 请求的页码 非必填,默认为1,有效范围 [1, ∞) |
| pageSize | Integer | 每页的记录数 非必填,默认为20,有效范围[1,100] |
| path | 版本 | 是否需要登录 |
|---|---|---|
| /home/paas/cluster/edge/query | 1.0.0 | 否 |
| 字段 | 类型 | 是否必传 | 备注 |
|---|---|---|---|
| pageNo | Integer | 是 | 请求的页码,请求的页码,详细见上述分页参数定义。 |
| pageSize | Integer | 是 | 每页的记录数,详细见请求的页码,详细见上述分页参数定义。 |
| 字段 | 类型 | 备注 |
|---|---|---|
| code | Integer | 返回码 |
| message | String | 返回信息 |
| data | JSONObject | |
| -data | ClusterDTOList | 分页数据对象列表ClusterDTOList |
| -pageNo | Integer | 请求的页码,详细见请求的页码,详细见上述分页参数定义。 |
| -pageSize | Integer | 请求的页码,详细见请求的页码,详细见上述分页参数定义。 |
| -total | Integer | 总记录数 |
分页数据对象ClusterDTOList
| id | String | 集群ID |
|---|---|---|
| name | String | 集群名称 |
| gmtCreate | String | 集群创建时间 |
| gmtModified | String | 集群修改时间 |
请求示例
{"pageNo":1,"pageSize":20}
返回示例
{"code": 200,"message": null,"localizedMsg": null,"data":{"pageNo": 1,"pageSize": 20,"total": 10,"data":[{"id": "xxx","name": "cluster01","gmtCreate": "2020-03-04 18:00:00","gmtModified": "2020-03-04 18:00:00"}]}}
| path | 版本 | 是否需要登录 |
|---|---|---|
| /home/paas/data/edge/sync/precheck | 1.0.0 | 否 |
| 字段 | 类型 | 是否必传 | 备注 |
|---|---|---|---|
| clusterId | String | 是 | 集群ID |
| opsType | String | 是 | SYNC_DATA - 同步数据 CLEAR_DATA - 清理数据 |
| dataTypeList | JSONArray | 是 | 数据类型列表 |
| 字段 | 类型 | 备注 |
|---|---|---|
| code | Integer | 返回码 |
| message | String | 返回信息 |
| data | String | SYNCING - 同步中 NO - 不需要同步 YES - 需要同步 |
请求示例
{"clusterId": "xxx","opsType": "SYNC_DATA","dataTypeList": ["ACCOUNT","SPACE"
工作时间5-10分钟将由1对1顾问为您提供尊享服务