You need to enable JavaScript to run this app.
导航

SetAppAlarmRule

最近更新时间2023.12.26 16:39:07

首次发布时间2022.11.18 17:53:52

调用SetAppAlarmRule接口新建或更新App报警任务。

使用说明

  • 接口名称:SetAppAlarmRule
  • 请求方式:POST
  • 接口地址:/?Action=SetAppAlarmRule&Version=2022-10-12

请求参数

Query

参数

类型

是否必选

示例值

描述

Action

String

SetAppAlarmRule

请求名称。

Version

String

2022-10-12

请求版本。

ServiceName : apmplus_openapi
Region : cn-beijing 
X-App-Ids : xxx
Content-Type : application/json

Body

参数

类型

是否必选

示例值

描述

id

i64

1

报警规则ID,如果是新建的可以不传。

name

string

task_test

规则名称。

description

string

alarm for xxx

规则描述。

monitor_types

array of string

["crash"]

监控类型。

  • crash:崩溃
  • crash_defend:崩溃防护
  • lag:卡顿
  • flutter_crash:flutter监控
  • app_page_js_err:页面监控/js错误
  • app_page_ajax_err:页面监控/请求错误
  • app_page_perf:页面监控/性能
  • app_event:事件报警
  • net_err:网络错误
  • custom_exception:自定义错误
  • traffic_exception:流量
  • disk_exception:磁盘
  • battery_trace:电量
  • cpu_exception:CPU

alarm_level

string

warning

报警级别。

  • warning
  • fatal

check_cycle

i64

5

监测周期,分钟为单位,瞬时报警请填0。

activations

array of Activation

-

多个时间段。

filter

object of Filter

-

报警指标筛选条件。

group_bys

array of GroupBy

-

报警分组条件。

hit_rule

object of HitRule

-

报警触发条件。

notice_conf

object of NoticeConf

-

通知配置信息。

Activation

参数

类型

是否必选

示例值

描述

activation_start

string

08:00

全天生效时间起点,24h制,精确到分。
例如,早上9点为"09:00"

activation_end

string

23:00

全天生效时间终点,24h制,精确到分。
例如,晚上11点为"23:00"。

Filter

参数

类型

是否必选

示例值

描述

type

string

and

条件类型。

  • expression:表达式
  • and:且条件
  • or:或条件

dimension

string

aid

条件的名称。

op

string

in

操作符。

  • in:包含

value

string

123456

筛选值。

values

array of string

[123456]

筛选值,支持多选。

sub_conditions

array of Filter

-

子条件。

GroupBy

参数

类型

是否必选

示例值

描述

dimension

string

path

分组名称。

HitRule

参数

类型

是否必选

示例值

描述

type

string

and

条件类型。

  • expression:表达式
  • and:且条件
  • or:或条件

hit_rule_type

string

threshold

规则类型。

  • threshold:阈值
  • compare:同环比

threshold_calculate_type

string

-

阈值计算方式,是纯做加减还是做百分比。

threshold_value

double

10000

报警阈值。

op

string

gt

比较符。

  • gt:>
  • gte:≥
  • lt:<
  • lte:≤
  • eq:=

indicator

object of Indicator

-

阈值类型参数配置。

indicators

array of Indicator

-

同环比类型参数配置。

sub_hit_rules

array of HitRule

-

子规则。

NoticeConf

参数

类型

是否必选

示例值

描述

type

array of string

mail

通知类型。

  • lark:飞书
  • mail:邮箱
  • dingding:钉钉
  • wechat:企业微信

lark_web_hooks

array of string

-

增加lark的webhook链接配置项。

dingding_web_hooks

array of string

-

钉钉webhook。

wechat_web_hooks

array of string

-

微信webhook

alarm_receives

array of AlarmReceive

-

接收组。

Indicator

参数

类型

是否必选

示例值

描述

name

string

crash_count

指标定义名称,由GetAppAlarmMetricsConf接口获取。

value

double

10

指标值。

recently

i64

180

指标查询时间范围,比如180min。

compare_time

i64

0

比较时间。

  • 5:前五分钟
  • 0:当前

start_time

i64

-

统计起止时间。

end_time

i64

-

统计起止时间。

AlarmReceive

参数

类型

是否必选

示例值

描述

is_group

boolean

true

是否接收组。

user_name

string

-

单个用户。

email

string

-

群组。

group_name

string

-

群组名。

group_id

i32

123

接收组ID。

返回参数

参数

类型

示例值

描述

error_msg

string

-

错误信息,成功为空。

error_no

i32

0

错误码,成功为0。

请求示例

POST https://open.volcengineapi.com/?Action=SetAppAlarmRule&Version=2022-10-12 

{
    "name": "测试报警0401",
    "description": "",
    "alarm_level": "fatal",
    "filter": {
        "type": "and",
        "sub_conditions": [
            {
                "dimension": "aid",
                "type": "expression",
                "op": "in",
                "values": [
                    "123456"
                ]
            }
        ]
    },
    "hit_rule": {
        "type": "and",
        "sub_hit_rules": [
            {
                "type": "expression",
                "hit_rule_type": "threshold",
                "indicator": {
                    "name": "crash_count",
                    "recently": 180,
                    "compare_time": 0
                },
                "threshold_calculate_type": "",
                "threshold_value": 1,
                "op": "gte"
            }
        ]
    },
    "check_cycle": 5,
    "activations": [
        {
            "activation_start": "00:00",
            "activation_end": "23:59"
        }
    ],
    "group_bys": [
        {
            "dimension": "os"
        }
    ],
    "notice_conf": {
        "type": [
            "lark"
        ],
        "lark_web_hooks": [
            "https://open.feishu.cn/open-apis/bot/v2/hook/f135"
        ]
    },
    "monitor_type": [
        "crash"
    ],
    "id": 12345
}

返回示例

正常返回示例

{
    "error_msg": "",
    "error_no": 0
}

异常返回示例

{
    "ResponseMetadata": {
        "RequestId": "201806*****2D30",
        "Action": "SetAppAlarmRule",
        "Version": "2022-10-12",
        "Service": "***",
        "Region": "cn-north-1",
        "Error": {
            "Code": "200000",
            "Message": "参数异常"
        }
    }
}