1. 数据预警
1.1. 1.1. POST 创建数据预警条目
POST /api/apps/{appId}/alert
创建属于特定应用的数据预警条目,一个APP最多创建20条预警条目
Body 请求参数
{
"title": "测试预警1",
"appId": 128149,
"dashboardId": 1,
"chartId": 5,
"options": {
"rules": [
{
"kind": "function",
"op": "and",
"args": [
{
"kind": "function",
"op": "!=",
"args": [
{
"kind": "reference",
"op": "u_32a8edf1946cd3c3_1",
"type": "number"
},
{
"kind": "constant",
"op": "0",
"type": "number"
}
]
}
]
}
],
"timing": {
"cronType": "WEEKLY",
"cronDesc": "0 0 0 ? * 1",
"timeZone": "GMT+08:00",
"triggerType": "CRON_JOB",
"frequency": "ONLY_ONCE"
},
"email": {
"enabled": true,
"config": {
"receiverList": [
{
"id": 26889,
"name": "测试用户",
"loginName": "test1",
"receiverType": "USER"
}
],
"emailSubject": "",
"emailContentBody": "指标已达预警阈值,请知晓并及时处理。<br /><br />预警规则被触发<br />id(求和) != 0<br />指标当前数据如下(只预览最多20条数据,可打开仪表盘链接查看详情):<br />{{%%system.chart.data}}<br /><br />应用:{{%%system.app.title}}<br />仪表盘:{{%%system.dashboard.title}}<br />图表:{{%%system.chart.title}}<br />",
"defaultEmailSubject": "【指标预警通知】{{%%system.dashboard.title}}:id",
"defaultEmailContentBody": "指标已达预警阈值,请知晓并及时处理。<br /><br />预警规则被触发<br />id(求和) != 0<br />指标当前数据如下(只预览最多20条数据,可打开仪表盘链接查看详情):<br />{{%%system.chart.data}}<br /><br />应用:{{%%system.app.title}}<br />仪表盘:{{%%system.dashboard.title}}<br />图表:{{%%system.chart.title}}<br />",
"bodyWithDashboardUrl": true,
"emailSubjectCustomized": false,
"emailBodyCustomized": true
}
},
"webhook": {
"enabled": true,
"config": {
"url": "https://www.baidu.com",
"method": "POST",
"headers": [],
"requestBody": ""
}
}
},
"errorPolice": {
"canPause": true,
"interval": 5,
"retryable": true,
"notifyUser": true,
"retryTimes": 2,
"failureTimes": 3
}
}
1.1.1. 1.1.1. 请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| appId | path | string | 是 | none |
| requestId | query | string | 否 | none |
| body | body | object | 是 | none |
| » title | body | string | 是 | 预警标题 |
| » appId | body | integer | 是 | 预警所属 app id |
| » dashboardId | body | integer | 是 | 预警条件所选dashboard id |
| » chartId | body | integer | 是 | 预警条件所选chart id |
| » options | body | object | 是 | 预警配置信息 |
| »» rules | body | [object] | 是 | 预警触发条件,HE数组。可以有多个条件,每个条件为一个数组项。 |
| »»» kind | body | string | 否 | none |
| »»» op | body | string | 否 | none |
| »»» args | body | [object] | 否 | none |
| »»»» kind | body | string | 否 | none |
| »»»» op | body | string | 否 | none |
| »»»» args | body | [object] | 否 | none |
| »»»»» kind | body | string | 是 | none |
| »»»»» op | body | string | 是 | none |
| »»»»» type | body | string | 是 | none |
| »» timing | body | object | 是 | 触发时机配置信息 |
| »»» cronType | body | string | 是 | cronType表达式类型 |
| »»» cronDesc | body | string | 是 | cron表达式 |
| »»» timeZone | body | string | 是 | 时区 |
| »»» triggerType | body | string | 是 | 值为(CRON_JOB) |
| »»» frequency | body | string | 是 | 频率,值为(ALWAYS,ONLY_ONCE,ONCE_EVERYDAY)之一 |
| body | object | 是 | 邮件通知配置信息 | |
| »»» enabled | body | boolean | 是 | 是否启用 |
| »»» config | body | object | 是 | 邮件信息 |
| »»»» receiverList | body | [object] | 是 | 接受人列表 |
| »»»»» id | body | integer | 否 | 接受者id |
| »»»»» name | body | string | 否 | 接受者名称 |
| »»»»» loginName | body | string | 否 | none |
| »»»»» receiverType | body | string | 否 | 接受者类型(USER,ORGANIZATION,DEPARTMENT)三者之一 |
| »»»» emailSubject | body | string | 否 | 自定义邮件主题 |
| »»»» emailContentBody | body | string | 否 | 自定义邮件内容 |
| »»»» defaultEmailSubject | body | string | 是 | 默认邮件主题 |
| »»»» defaultEmailContentBody | body | string | 是 | 默认邮件内容 |
| »»»» bodyWithDashboardUrl | body | boolean | 是 | 邮件是否携带仪表盘URL |
| »»»» emailSubjectCustomized | body | boolean | 是 | 是否使用自定义邮件主题 |
| »»»» emailBodyCustomized | body | boolean | 是 | 是否使用自定义邮件内容 |
| »» webhook | body | object | 是 | webhook通知配置信息 |
| »»» enabled | body | boolean | 是 | 是否启用webhook |
| »»» config | body | object | 是 | webhook配置信息 |
| »»»» url | body | string | 是 | 请求url |
| »»»» method | body | string | 是 | 请求方法 |
| »»»» headers | body | [string] | 是 | 请求头 |
| »»»» requestBody | body | string | 是 | 请求体(仅支持json格式请求体) |
| » errorPolice | body | object | 是 | 预警失败策略 |
| »» canPause | body | boolean | 是 | 能否暂停任务,暂停任务后需手动重新启动。 |
| »» interval | body | integer | 是 | 重试间隔时间,单位:分钟 |
| »» retryable | body | boolean | 是 | 能否重试 |
| »» notifyUser | body | boolean | 是 | 任务暂停后是否通知应用所有者 |
| »» retryTimes | body | integer | 是 | 重试总次数 |
| »» failureTimes | body | integer | 是 | 失败暂停阈值 |
返回示例
成功
{
"version": "4.5-SNAPSHOT@163f990#73d0999",
"code": 0,
"msg": "success",
"data": {
"id": 213,
"title": "测试预警3",
"appId": 128149,
"dashboardId": 1,
"chartId": 5,
"options": {
"rules": [
{
"args": [
{
"args": [
{
"op": "u_32a8edf1946cd3c3_1",
"kind": "reference",
"type": "number"
},
{
"op": "0",
"kind": "constant",
"type": "number"
}
],
"op": "!=",
"kind": "function"
}
],
"op": "and",
"kind": "function"
}
],
"email": {
"enabled": true,
"config": {
"receiverList": [
{
"id": 26889,
"name": "测试用户",
"loginName": "test1",
"receiverType": "USER"
}
],
"dashboardList": [
{
"id": 1,
"title": "新建仪表盘"
}
],
"emailSubjectCustomized": false,
"emailBodyCustomized": true,
"emailSubject": "",
"defaultEmailSubject": "【指标预警通知】{{%%system.dashboard.title}}:id",
"emailContentBody": "指标已达预警阈值,请知晓并及时处理。<br /><br />预警规则被触发<br />id(求和) != 0<br />指标当前数据如下(只预览最多20条数据,可打开仪表盘链接查看详情):<br />{{%%system.chart.data}}<br /><br />应用:{{%%system.app.title}}<br />仪表盘:{{%%system.dashboard.title}}<br />图表:{{%%system.chart.title}}<br />",
"defaultEmailContentBody": "指标已达预警阈值,请知晓并及时处理。<br /><br />预警规则被触发<br />id(求和) != 0<br />指标当前数据如下(只预览最多20条数据,可打开仪表盘链接查看详情):<br />{{%%system.chart.data}}<br /><br />应用:{{%%system.app.title}}<br />仪表盘:{{%%system.dashboard.title}}<br />图表:{{%%system.chart.title}}<br />",
"bodyWithDashboardUrl": true
}
},
"webhook": {
"enabled": true,
"config": {
"url": "https://www.baidu.com",
"method": "POST",
"headers": [],
"requestBody": ""
}
},
"timing": {
"triggerType": "CRON_JOB",
"cronDesc": "0 0 0 ? * 1",
"cronType": "WEEKLY",
"timeZone": "GMT+08:00",
"frequency": "ONLY_ONCE"
}
},
"status": "RUNNING",
"enabled": true,
"createdBy": 11549,
"updatedBy": 11549,
"createdAt": "2023-07-11 14:38:51",
"updatedAt": "2023-07-11 14:38:51",
"isDelete": false,
"hsVersion": 0,
"errorPolice": {
"retryable": true,
"interval": 5,
"retryTimes": 2,
"canPause": true,
"failureTimes": 3,
"notifyUser": true
}
},
"chartDataStartTimeMillis": 0
}
1.1.2. 1.1.2. 返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 成功 | Inline |
1.1.3. 1.1.3. 返回数据结构
状态码 200
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » version | string | true | none | none | |
| » code | integer | true | none | none | |
| » msg | string | true | none | none | |
| » data | object | true | none | none | |
| »» id | integer | true | none | none | |
| »» title | string | true | none | none | |
| »» appId | integer | true | none | none | |
| »» dashboardId | integer | true | none | none | |
| »» chartId | integer | true | none | none | |
| »» options | object | true | none | none | |
| »»» rules | [object] | true | none | none | |
| »»»» args | [object] | false | none | none | |
| »»»»» args | [object] | false | none | none | |
| »»»»»» op | string | true | none | none | |
| »»»»»» kind | string | true | none | none | |
| »»»»»» type | string | true | none | none | |
| »»»»» op | string | false | none | none | |
| »»»»» kind | string | false | none | none | |
| »»»» op | string | false | none | none | |
| »»»» kind | string | false | none | none | |
| object | true | none | none | ||
| »»»» enabled | boolean | true | none | none | |
| »»»» config | object | true | none | none | |
| »»»»» receiverList | [object] | true | none | none | |
| »»»»»» id | integer | false | none | none | |
| »»»»»» name | string | false | none | none | |
| »»»»»» loginName | string | false | none | none | |
| »»»»»» receiverType | string | false | none | none | |
| »»»»» dashboardList | [object] | true | none | none | |
| »»»»»» id | integer | false | none | none | |
| »»»»»» title | string | false | none | none | |
| »»»»» emailSubjectCustomized | boolean | true | none | none | |
| »»»»» emailBodyCustomized | boolean | true | none | none | |
| »»»»» emailSubject | string | true | none | none | |
| »»»»» defaultEmailSubject | string | true | none | none | |
| »»»»» emailContentBody | string | true | none | none | |
| »»»»» defaultEmailContentBody | string | true | none | none | |
| »»»»» bodyWithDashboardUrl | boolean | true | none | none | |
| »»» webhook | object | true | none | none | |
| »»»» enabled | boolean | true | none | none | |
| »»»» config | object | true | none | none | |
| »»»»» url | string | true | none | none | |
| »»»»» method | string | true | none | none | |
| »»»»» headers | [string] | true | none | none | |
| »»»»» requestBody | string | true | none | none | |
| »»» timing | object | true | none | none | |
| »»»» triggerType | string | true | none | none | |
| »»»» cronDesc | string | true | none | none | |
| »»»» cronType | string | true | none | none | |
| »»»» timeZone | string | true | none | none | |
| »»»» frequency | string | true | none | none | |
| »» status | string | true | none | none | |
| »» enabled | boolean | true | none | none | |
| »» createdBy | integer | true | none | none | |
| »» updatedBy | integer | true | none | none | |
| »» createdAt | string | true | none | none | |
| »» updatedAt | string | true | none | none | |
| »» isDelete | boolean | true | none | none | |
| »» hsVersion | integer | true | none | none | |
| »» errorPolice | object | true | none | none | |
| »»» retryable | boolean | true | none | none | |
| »»» interval | integer | true | none | none | |
| »»» retryTimes | integer | true | none | none | |
| »»» canPause | boolean | true | none | none | |
| »»» failureTimes | integer | true | none | none | |
| »»» notifyUser | boolean | true | none | none | |
| » chartDataStartTimeMillis | integer | true | none | none |
1.2. 1.2. GET 分页查询预警
GET /api/apps/{appId}/alert/list
1.2.1. 1.2.1. 请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| appId | path | string | 是 | none |
| requestId | query | string | 否 | none |
| offset | query | Long | 否 | none |
| limit | query | Long | 否 | none |
1.3. 1.3. DELETE 删除预警条目
DELETE /api/apps/{appId}/alert/{alertId}
1.3.1. 1.3.1. 请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| appId | path | string | 是 | none |
| alertId | path | string | 是 | none |
| requestId | query | string | 否 | none |
1.4. 1.4. GET 根据ID查询预警
GET /api/apps/{appId}/alert/{alertId}
1.4.1. 1.4.1. 请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| appId | path | string | 是 | none |
| alertId | path | string | 是 | none |
| requestId | query | string | 否 | none |
1.5. 1.5. PUT 编辑数据预警条目
PUT /api/apps/{appId}/alert/{alertId}
编辑特定的预警条目
Body 请求参数
{
"title": "测试预警1",
"appId": 128149,
"dashboardId": 1,
"chartId": 5,
"options": {
"rules": [
{
"kind": "function",
"op": "and",
"args": [
{
"kind": "function",
"op": "!=",
"args": [
{
"kind": "reference",
"op": "u_32a8edf1946cd3c3_1",
"type": "number"
},
{
"kind": "constant",
"op": "0",
"type": "number"
}
]
}
]
}
],
"timing": {
"cronType": "WEEKLY",
"cronDesc": "0 0 0 ? * 1",
"timeZone": "GMT+08:00",
"triggerType": "CRON_JOB",
"frequency": "ONLY_ONCE"
},
"email": {
"enabled": true,
"config": {
"receiverList": [
{
"id": 26889,
"name": "测试用户",
"loginName": "test1",
"receiverType": "USER"
}
],
"emailSubject": "",
"emailContentBody": "指标已达预警阈值,请知晓并及时处理。<br /><br />预警规则被触发<br />id(求和) != 0<br />指标当前数据如下(只预览最多20条数据,可打开仪表盘链接查看详情):<br />{{%%system.chart.data}}<br /><br />应用:{{%%system.app.title}}<br />仪表盘:{{%%system.dashboard.title}}<br />图表:{{%%system.chart.title}}<br />",
"defaultEmailSubject": "【指标预警通知】{{%%system.dashboard.title}}:id",
"defaultEmailContentBody": "指标已达预警阈值,请知晓并及时处理。<br /><br />预警规则被触发<br />id(求和) != 0<br />指标当前数据如下(只预览最多20条数据,可打开仪表盘链接查看详情):<br />{{%%system.chart.data}}<br /><br />应用:{{%%system.app.title}}<br />仪表盘:{{%%system.dashboard.title}}<br />图表:{{%%system.chart.title}}<br />",
"bodyWithDashboardUrl": true,
"emailSubjectCustomized": false,
"emailBodyCustomized": true
}
},
"webhook": {
"enabled": true,
"config": {
"url": "https://www.baidu.com",
"method": "POST",
"headers": [],
"requestBody": ""
}
}
},
"errorPolice": {
"canPause": true,
"interval": 5,
"retryable": true,
"notifyUser": true,
"retryTimes": 2,
"failureTimes": 3
}
}
1.5.1. 1.5.1. 请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| appId | path | string | 是 | none |
| alertId | path | string | 是 | none |
| requestId | query | string | 否 | none |
| body | body | object | 是 | none |
| » title | body | string | 是 | 预警标题 |
| » appId | body | integer | 是 | 预警所属 app id |
| » dashboardId | body | integer | 是 | 预警条件所选dashboard id |
| » chartId | body | integer | 是 | 预警条件所选chart id |
| » options | body | object | 是 | 预警配置信息 |
| »» rules | body | [object] | 是 | 预警触发条件,HE数组。可以有多个条件,每个条件为一个数组项。 |
| »»» kind | body | string | 否 | none |
| »»» op | body | string | 否 | none |
| »»» args | body | [object] | 否 | none |
| »»»» kind | body | string | 否 | none |
| »»»» op | body | string | 否 | none |
| »»»» args | body | [object] | 否 | none |
| »»»»» kind | body | string | 是 | none |
| »»»»» op | body | string | 是 | none |
| »»»»» type | body | string | 是 | none |
| »» timing | body | object | 是 | 触发时机配置信息 |
| »»» cronType | body | string | 是 | cronType表达式类型 |
| »»» cronDesc | body | string | 是 | cron表达式 |
| »»» timeZone | body | string | 是 | 时区 |
| »»» triggerType | body | string | 是 | 值为(CRON_JOB) |
| »»» frequency | body | string | 是 | 频率,值为(ALWAYS,ONLY_ONCE,ONCE_EVERYDAY)之一 |
| body | object | 是 | 邮件通知配置信息 | |
| »»» enabled | body | boolean | 是 | 是否启用 |
| »»» config | body | object | 是 | 邮件信息 |
| »»»» receiverList | body | [object] | 是 | 接受人列表 |
| »»»»» id | body | integer | 否 | 接受者id |
| »»»»» name | body | string | 否 | 接受者名称 |
| »»»»» loginName | body | string | 否 | none |
| »»»»» receiverType | body | string | 否 | 接受者类型(USER,ORGANIZATION,DEPARTMENT)三者之一 |
| »»»» emailSubject | body | string | 否 | 自定义邮件主题 |
| »»»» emailContentBody | body | string | 否 | 自定义邮件内容 |
| »»»» defaultEmailSubject | body | string | 是 | 默认邮件主题 |
| »»»» defaultEmailContentBody | body | string | 是 | 默认邮件内容 |
| »»»» bodyWithDashboardUrl | body | boolean | 是 | 邮件是否携带仪表盘URL |
| »»»» emailSubjectCustomized | body | boolean | 是 | 是否使用自定义邮件主题 |
| »»»» emailBodyCustomized | body | boolean | 是 | 是否使用自定义邮件内容 |
| »» webhook | body | object | 是 | webhook通知配置信息 |
| »»» enabled | body | boolean | 是 | 是否启用webhook |
| »»» config | body | object | 是 | webhook配置信息 |
| »»»» url | body | string | 是 | 请求url |
| »»»» method | body | string | 是 | 请求方法 |
| »»»» headers | body | [string] | 是 | 请求头 |
| »»»» requestBody | body | string | 是 | 请求体(仅支持json格式请求体) |
| » errorPolice | body | object | 是 | 预警失败策略 |
| »» canPause | body | boolean | 是 | 能否暂停任务,暂停任务后需手动重新启动。 |
| »» interval | body | integer | 是 | 重试间隔时间,单位:分钟 |
| »» retryable | body | boolean | 是 | 能否重试 |
| »» notifyUser | body | boolean | 是 | 任务暂停后是否通知应用所有者 |
| »» retryTimes | body | integer | 是 | 重试总次数 |
| »» failureTimes | body | integer | 是 | 失败暂停阈值 |
返回示例
成功
{
"version": "4.5-SNAPSHOT@163f990#73d0999",
"code": 0,
"msg": "success",
"data": {
"id": 213,
"title": "测试预警3",
"appId": 128149,
"dashboardId": 1,
"chartId": 5,
"options": {
"rules": [
{
"args": [
{
"args": [
{
"op": "u_32a8edf1946cd3c3_1",
"kind": "reference",
"type": "number"
},
{
"op": "0",
"kind": "constant",
"type": "number"
}
],
"op": "!=",
"kind": "function"
}
],
"op": "and",
"kind": "function"
}
],
"email": {
"enabled": true,
"config": {
"receiverList": [
{
"id": 26889,
"name": "测试用户",
"loginName": "test1",
"receiverType": "USER"
}
],
"dashboardList": [
{
"id": 1,
"title": "新建仪表盘"
}
],
"emailSubjectCustomized": false,
"emailBodyCustomized": true,
"emailSubject": "",
"defaultEmailSubject": "【指标预警通知】{{%%system.dashboard.title}}:id",
"emailContentBody": "指标已达预警阈值,请知晓并及时处理。<br /><br />预警规则被触发<br />id(求和) != 0<br />指标当前数据如下(只预览最多20条数据,可打开仪表盘链接查看详情):<br />{{%%system.chart.data}}<br /><br />应用:{{%%system.app.title}}<br />仪表盘:{{%%system.dashboard.title}}<br />图表:{{%%system.chart.title}}<br />",
"defaultEmailContentBody": "指标已达预警阈值,请知晓并及时处理。<br /><br />预警规则被触发<br />id(求和) != 0<br />指标当前数据如下(只预览最多20条数据,可打开仪表盘链接查看详情):<br />{{%%system.chart.data}}<br /><br />应用:{{%%system.app.title}}<br />仪表盘:{{%%system.dashboard.title}}<br />图表:{{%%system.chart.title}}<br />",
"bodyWithDashboardUrl": true
}
},
"webhook": {
"enabled": true,
"config": {
"url": "https://www.baidu.com",
"method": "POST",
"headers": [],
"requestBody": ""
}
},
"timing": {
"triggerType": "CRON_JOB",
"cronDesc": "0 0 0 ? * 1",
"cronType": "WEEKLY",
"timeZone": "GMT+08:00",
"frequency": "ONLY_ONCE"
}
},
"status": "RUNNING",
"enabled": true,
"createdBy": 11549,
"updatedBy": 11549,
"createdAt": "2023-07-11 14:38:51",
"updatedAt": "2023-07-11 14:38:51",
"isDelete": false,
"hsVersion": 0,
"errorPolice": {
"retryable": true,
"interval": 5,
"retryTimes": 2,
"canPause": true,
"failureTimes": 3,
"notifyUser": true
}
},
"chartDataStartTimeMillis": 0
}
1.5.2. 1.5.2. 返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 成功 | Inline |
1.5.3. 1.5.3. 返回数据结构
状态码 200
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » version | string | true | none | none | |
| » code | integer | true | none | none | |
| » msg | string | true | none | none | |
| » data | object | true | none | none | |
| »» id | integer | true | none | none | |
| »» title | string | true | none | none | |
| »» appId | integer | true | none | none | |
| »» dashboardId | integer | true | none | none | |
| »» chartId | integer | true | none | none | |
| »» options | object | true | none | none | |
| »»» rules | [object] | true | none | none | |
| »»»» args | [object] | false | none | none | |
| »»»»» args | [object] | false | none | none | |
| »»»»»» op | string | true | none | none | |
| »»»»»» kind | string | true | none | none | |
| »»»»»» type | string | true | none | none | |
| »»»»» op | string | false | none | none | |
| »»»»» kind | string | false | none | none | |
| »»»» op | string | false | none | none | |
| »»»» kind | string | false | none | none | |
| object | true | none | none | ||
| »»»» enabled | boolean | true | none | none | |
| »»»» config | object | true | none | none | |
| »»»»» receiverList | [object] | true | none | none | |
| »»»»»» id | integer | false | none | none | |
| »»»»»» name | string | false | none | none | |
| »»»»»» loginName | string | false | none | none | |
| »»»»»» receiverType | string | false | none | none | |
| »»»»» dashboardList | [object] | true | none | none | |
| »»»»»» id | integer | false | none | none | |
| »»»»»» title | string | false | none | none | |
| »»»»» emailSubjectCustomized | boolean | true | none | none | |
| »»»»» emailBodyCustomized | boolean | true | none | none | |
| »»»»» emailSubject | string | true | none | none | |
| »»»»» defaultEmailSubject | string | true | none | none | |
| »»»»» emailContentBody | string | true | none | none | |
| »»»»» defaultEmailContentBody | string | true | none | none | |
| »»»»» bodyWithDashboardUrl | boolean | true | none | none | |
| »»» webhook | object | true | none | none | |
| »»»» enabled | boolean | true | none | none | |
| »»»» config | object | true | none | none | |
| »»»»» url | string | true | none | none | |
| »»»»» method | string | true | none | none | |
| »»»»» headers | [string] | true | none | none | |
| »»»»» requestBody | string | true | none | none | |
| »»» timing | object | true | none | none | |
| »»»» triggerType | string | true | none | none | |
| »»»» cronDesc | string | true | none | none | |
| »»»» cronType | string | true | none | none | |
| »»»» timeZone | string | true | none | none | |
| »»»» frequency | string | true | none | none | |
| »» status | string | true | none | none | |
| »» enabled | boolean | true | none | none | |
| »» createdBy | integer | true | none | none | |
| »» updatedBy | integer | true | none | none | |
| »» createdAt | string | true | none | none | |
| »» updatedAt | string | true | none | none | |
| »» isDelete | boolean | true | none | none | |
| »» hsVersion | integer | true | none | none | |
| »» errorPolice | object | true | none | none | |
| »»» retryable | boolean | true | none | none | |
| »»» interval | integer | true | none | none | |
| »»» retryTimes | integer | true | none | none | |
| »»» canPause | boolean | true | none | none | |
| »»» failureTimes | integer | true | none | none | |
| »»» notifyUser | boolean | true | none | none | |
| » chartDataStartTimeMillis | integer | true | none | none |
1.6. 1.6. POST 验证预警条目
POST /api/apps/{appId}/alert/validate
验证预警配置
Body 请求参数
{
"id": "123",
"title": "测试预警1",
"appId": 128149,
"dashboardId": 1,
"chartId": 5,
"options": {
"rules": [
{
"kind": "function",
"op": "and",
"args": [
{
"kind": "function",
"op": "!=",
"args": [
{
"kind": "reference",
"op": "u_32a8edf1946cd3c3_1",
"type": "number"
},
{
"kind": "constant",
"op": "0",
"type": "number"
}
]
}
]
}
],
"timing": {
"cronType": "WEEKLY",
"cronDesc": "0 0 0 ? * 1",
"timeZone": "GMT+08:00",
"triggerType": "CRON_JOB",
"frequency": "ONLY_ONCE"
},
"email": {
"enabled": true,
"config": {
"receiverList": [
{
"id": 26889,
"name": "测试用户",
"loginName": "test1",
"receiverType": "USER"
}
],
"emailSubject": "",
"emailContentBody": "指标已达预警阈值,请知晓并及时处理。<br /><br />预警规则被触发<br />id(求和) != 0<br />指标当前数据如下(只预览最多20条数据,可打开仪表盘链接查看详情):<br />{{%%system.chart.data}}<br /><br />应用:{{%%system.app.title}}<br />仪表盘:{{%%system.dashboard.title}}<br />图表:{{%%system.chart.title}}<br />",
"defaultEmailSubject": "【指标预警通知】{{%%system.dashboard.title}}:id",
"defaultEmailContentBody": "指标已达预警阈值,请知晓并及时处理。<br /><br />预警规则被触发<br />id(求和) != 0<br />指标当前数据如下(只预览最多20条数据,可打开仪表盘链接查看详情):<br />{{%%system.chart.data}}<br /><br />应用:{{%%system.app.title}}<br />仪表盘:{{%%system.dashboard.title}}<br />图表:{{%%system.chart.title}}<br />",
"bodyWithDashboardUrl": true,
"emailSubjectCustomized": false,
"emailBodyCustomized": true
}
},
"webhook": {
"enabled": true,
"config": {
"url": "https://www.baidu.com",
"method": "POST",
"headers": [],
"requestBody": ""
}
}
},
"errorPolice": {
"canPause": true,
"interval": 5,
"retryable": true,
"notifyUser": true,
"retryTimes": 2,
"failureTimes": 3
}
}
1.6.1. 1.6.1. 请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| appId | path | string | 是 | none |
| requestId | query | string | 否 | none |
| body | body | object | 是 | none |
| » title | body | string | 是 | 预警标题 |
| » id | body | string | 否 | 预警id |
| » appId | body | integer | 是 | 预警所属 app id |
| » dashboardId | body | integer | 是 | 预警条件所选dashboard id |
| » chartId | body | integer | 是 | 预警条件所选chart id |
| » options | body | object | 是 | 预警配置信息 |
| »» rules | body | [object] | 是 | 预警触发条件,HE数组。可以有多个条件,每个条件为一个数组项。 |
| »»» kind | body | string | 否 | none |
| »»» op | body | string | 否 | none |
| »»» args | body | [object] | 否 | none |
| »»»» kind | body | string | 否 | none |
| »»»» op | body | string | 否 | none |
| »»»» args | body | [object] | 否 | none |
| »»»»» kind | body | string | 是 | none |
| »»»»» op | body | string | 是 | none |
| »»»»» type | body | string | 是 | none |
| »» timing | body | object | 是 | 触发时机配置信息 |
| »»» cronType | body | string | 是 | cronType表达式类型 |
| »»» cronDesc | body | string | 是 | cron表达式 |
| »»» timeZone | body | string | 是 | 时区 |
| »»» triggerType | body | string | 是 | 值为(CRON_JOB) |
| »»» frequency | body | string | 是 | 频率,值为(ALWAYS,ONLY_ONCE,ONCE_EVERYDAY)之一 |
| body | object | 是 | 邮件通知配置信息 | |
| »»» enabled | body | boolean | 是 | 是否启用 |
| »»» config | body | object | 是 | 邮件信息 |
| »»»» receiverList | body | [object] | 是 | 接受人列表 |
| »»»»» id | body | integer | 否 | 接受者id |
| »»»»» name | body | string | 否 | 接受者名称 |
| »»»»» loginName | body | string | 否 | none |
| »»»»» receiverType | body | string | 否 | 接受者类型(USER,ORGANIZATION,DEPARTMENT)三者之一 |
| »»»» emailSubject | body | string | 否 | 自定义邮件主题 |
| »»»» emailContentBody | body | string | 否 | 自定义邮件内容 |
| »»»» defaultEmailSubject | body | string | 是 | 默认邮件主题 |
| »»»» defaultEmailContentBody | body | string | 是 | 默认邮件内容 |
| »»»» bodyWithDashboardUrl | body | boolean | 是 | 邮件是否携带仪表盘URL |
| »»»» emailSubjectCustomized | body | boolean | 是 | 是否使用自定义邮件主题 |
| »»»» emailBodyCustomized | body | boolean | 是 | 是否使用自定义邮件内容 |
| »» webhook | body | object | 是 | webhook通知配置信息 |
| »»» enabled | body | boolean | 是 | 是否启用webhook |
| »»» config | body | object | 是 | webhook配置信息 |
| »»»» url | body | string | 是 | 请求url |
| »»»» method | body | string | 是 | 请求方法 |
| »»»» headers | body | [string] | 是 | 请求头 |
| »»»» requestBody | body | string | 是 | 请求体(仅支持json格式请求体) |
| » errorPolice | body | object | 是 | 预警失败策略 |
| »» canPause | body | boolean | 是 | 能否暂停任务,暂停任务后需手动重新启动。 |
| »» interval | body | integer | 是 | 重试间隔时间,单位:分钟 |
| »» retryable | body | boolean | 是 | 能否重试 |
| »» notifyUser | body | boolean | 是 | 任务暂停后是否通知应用所有者 |
| »» retryTimes | body | integer | 是 | 重试总次数 |
| »» failureTimes | body | integer | 是 | 失败暂停阈值 |
返回示例
成功
{
"version": "4.5-SNAPSHOT@163f990#73d0999",
"code": 0,
"msg": "success",
"chartDataStartTimeMillis": 0
}
1.6.2. 1.6.2. 返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 成功 | Inline |
1.6.3. 1.6.3. 返回数据结构
状态码 200
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » version | string | true | none | none | |
| » code | integer | true | none | none | |
| » msg | string | true | none | none | |
| » chartDataStartTimeMillis | integer | true | none | none |