CreateLogPolicy

最近更新时间:2023-03-30 11:36:36

查看PDF

接口描述

本接口用于根据已有仪表盘创建告警策略

请求参数

该接口无特有请求头。获取更多信息,请参见公共请求头
参数详情具体如下表。

参数名称 类型 是否必须 描述
name String 告警名称
projectName String 工程名称
dashboardId String 仪表盘id
dashboardName String 仪表盘名称
queries List 查询
condition String 触发条件
scheduleType Long 频率类型:0:间隔时间 4:cron
fixInterval String 间隔时间
cronExpr String 频率为cron的表达式
notifyInterval Long 通知间隔
notifyThreshold Long 触发次数阈值
enabled Integer 是否启用 0:不启用 1: 启用
channelParam Map 报警渠道配置

querie字段说明:

参数名称 类型 描述
logPoolName String 日志池名称
graphName String 图表名称
start String 查开始区间
end String 查询结束区间
query String 查询语句

channelParam字段说明:

参数名称 类型 描述
usrgrpId Integer 告警接收组id,需要在云监控查询
channelType Integer 报警类型 1:邮件 2: 短信 3:邮件和短信
emailContent String 邮件报警内容格式
smsContent String 短信报警内容格式

响应参数

参数详情具体如下表。

参数名称 类型 描述
status Integer 状态码
message String 状态信息

示例

请求示例

POST /CreateLogPolicy HTTP/1.1
Authorization: <AuthorizationString>
x-klog-api-version: 0.1.0
Host:klog.api.ksyun.com
x-klog-signature-method: hmac-sha1
Date: <GMT Date>
Content-Type: application/json
Content-MD5: <Content-MD5>
Content-Length: <ContentLength>
Connection: Keep-Alive
{
    "name": "my-test",
    "projectName": "test",
    "dashboardId": "1",
    "dashboardName": "Warning",
    "queries": [
        {
            "logPoolName": "test",
            "graphName": "Warning",
            "start": "-300s",
            "end": "now",
            "query": "select count (*) as c where type='Warning'"
        }
    ],
    "channelParam": {
        "usrgrpId": 11,
        "channelType": 3,
        "emailContent": "Warning警示事件,发生告警,请排查相关问题"
    },
    "condition": "$0.c>0",
    "scheduleType": 0,
    "fixInterval": "5m",
    "notifyThreshold": 1,
    "notifyInterval": 0,
    "enabled": 1
}

响应示例

HTTP/1.1 200
Server: nginx
Content-Length: 0
Connection: close
Access-Control-Allow-Origin: *
Date: Sun, 27 May 2018 07:43:27 GMT
x-klog-requestid: 5B0A619F205DC3F30EDA9322
{
    "status": 0,
    "message": "成功",
}

文档内容是否对您有帮助?

根本没帮助
文档较差
文档一般
文档不错
文档很好

在文档使用中是否遇到以下问题

内容不全,不深入
内容更新不及时
描述不清晰,比较混乱
系统或功能太复杂,缺乏足够的引导
内容冗长

更多建议

0/200

评价建议不能为空

提交成功!

非常感谢您的反馈,我们会继续努力做到更好!

问题反馈