跳到主要内容

创建告警规则

本接口在指定项目中创建新的告警规则。当前用户须为项目管理员。
POST
/v2/alertRules
Base URL

该 API 的 Base URL 格式如下:

https://api.cloud.zilliz.com.cn

📘说明

控制面接口速率限制为单用户单接口每秒最多 20 个请求。

当前接口为公测版。如果您在使用该接口过程中遇到任何问题,欢迎您联系 Zilliz Cloud 技术支持

export BASE_URL="https://api.cloud.zilliz.com.cn"
参数
Authorizationstringheaderrequired

认证令牌,应为具备适当权限的 API 密钥。

示例值:Bearer {{TOKEN}}
Acceptstringheader

使用 application/json

示例值:application/json
请求体application/json
projectIdstring必填项

告警规则所属项目 ID。

ruleNamestring必填项

告警规则名称。

levelstring必填项

告警规则级别。

metricNamestring必填项

告警规则监控的指标名称。

thresholdstring

告警规则阈值。

windowSizestring

告警规则的时间窗口,单位为分钟。

comparisonOperatorstring

告警规则使用的比较运算符。

targetClusterIdsarray

告警规则适用的集群 ID 列表。

[]targetClusterIdsstring

集群 ID。

enabledboolean必填项

告警规则是否启用。

sendResolvedboolean必填项

告警规则是否发送已解决的通知。

actionsarrayrequired

The actions to take when the alert rule is triggered.

[]actionsobjectrequired

An action to take when the alert rule is triggered.

typestring必填项

操作类型。

configobjectrequired

操作配置。

recipientsobject

告警通知的接收者。仅当操作类型为 EMAIL 和 SMS 时适用。

membersarray

用于接收通知的邮件地址列表。

[]membersstring

用于接收通知的邮件地址。

orgRolesarray

用于接收通知的组织角色列表。

[]orgRolesstring

用于接收通知的组织角色。

projectRolesarray

用于接收通知的项目角色列表。

[]projectRolesstring

用于接收通知的项目角色。

urlstring

告警通知应发送到的 URL。仅当操作类型为 WEBHOOK 时适用。

webhookUrlstring

告警通知应发送到的 URL。仅当操作类型为 SLACK、LARK、WECOM 时适用。

regionstring

您的 PagerDuty 或 OpsGenie 服务所在的区域。仅当操作类型为 PAGERDUTY 和 OPSGENIE 时适用。

apiKeystring

您的 PagerDuty 或 OpsGenie 服务的 API 密钥。仅当操作类型为 PAGERDUTY 和 OPSGENIE 时适用。

export TOKEN="YOUR_API_KEY"

curl --request POST \
--url "${BASE_URL}/v2/alertRules" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
-d '{
"id": "12391290837zs09sad0d09123",
"projectId": "proj-b44a39b0c51cf21791a841",
"ruleName": "my alert name",
"level": "CRITICAL",
"metricName": "REQUEST_LATENCY_SEARCH_P99",
"threshold": "70",
"windowSize": "10",
"comparisonOperator": "GREATER_THAN",
"targetClusterIds": [
"in01-xxxxxxxxxxxx"
],
"enabled": true,
"sendResolved": true,
"actions": [
{
"type": "EMAIL",
"config": {
"recipients": {
"members": [
"your-email@your-org.com"
],
"orgRoles": [
"OWNER",
"MEMBER",
"BILLING_ADMIN"
],
"projectRoles": [
"OWNER",
"MEMBER"
]
}
}
},
{
"type": "SMS",
"config": {
"recipients": {
"members": [
"your-email@your-org.com"
],
"orgRoles": [
"OWNER",
"MEMBER",
"BILLING_ADMIN"
],
"projectRoles": [
"OWNER",
"MEMBER"
]
}
}
},
{
"type": "WEBHOOK",
"config": {
"url": "https://xxxx"
}
},
{
"type": "SLACK",
"config": {
"webhookUrl": "https://xxxx"
}
},
{
"type": "LARK",
"config": {
"webhookUrl": "https://xxxx"
}
},
{
"type": "WECOM",
"config": {
"webhookUrl": "https://xxxx"
}
},
{
"type": "PAGERDUTY",
"config": {
"region": "US",
"apiKey": "..."
}
},
{
"type": "OPSGENIE",
"config": {
"region": "US",
"apiKey": "..."
}
}
]
}'
响应200 - application/json

Returns a list of alert rules.

codeinteger

响应码。

dataobject
idstring

告警规则 ID。

projectIdstring

告警规则所属项目 ID。

ruleNamestring

告警规则名称。

levelstring

告警规则级别。

metricNamestring

告警规则监控的指标名称。

thresholdstring

告警规则阈值。

windowSizestring

告警规则的时间窗口,单位为分钟。

comparisonOperatorstring

告警规则使用的比较运算符。

targetClusterIdsarray

告警规则适用的集群 ID 列表。

[]targetClusterIdsstring

集群 ID。

enabledboolean

告警规则是否启用。

sendResolvedboolean

告警规则是否发送已解决的通知。

actionsarray

The actions to take when the alert rule is triggered.

[]actionsobject

An action to take when the alert rule is triggered.

typestring

操作类型。

configobject

操作配置。

recipientsobject

告警通知的接收者。仅当操作类型为 EMAIL 和 SMS 时适用。

membersarray

用于接收通知的邮件地址列表。

[]membersstring

用于接收通知的邮件地址。

orgRolesarray

用于接收通知的组织角色列表。

[]orgRolesstring

用于接收通知的组织角色。

projectRolesarray

用于接收通知的项目角色列表。

[]projectRolesstring

用于接收通知的项目角色。

urlstring

告警通知应发送到的 URL。仅当操作类型为 WEBHOOK 时适用。

webhookUrlstring

告警通知应发送到的 URL。仅当操作类型为 SLACK、LARK、WECOM 时适用。

regionstring

您的 PagerDuty 或 OpsGenie 服务所在的区域。仅当操作类型为 PAGERDUTY 和 OPSGENIE 时适用。

apiKeystring

您的 PagerDuty 或 OpsGenie 服务的 API 密钥。仅当操作类型为 PAGERDUTY 和 OPSGENIE 时适用。

Returns an error message.

codeinteger

响应码。

messagestring

错误描述。

{
"code": 0,
"data": {
"id": "12391290837zs09sad0d09123",
"projectId": "proj-b44a39b0c51cf21791a841",
"ruleName": "my alert name",
"level": "CRITICAL",
"metricName": "REQUEST_LATENCY_SEARCH_P99",
"threshold": "70",
"windowSize": "10",
"comparisonOperator": "GREATER_THAN",
"targetClusterIds": [
"in01-xxxxxxxxxxxx"
],
"enabled": true,
"sendResolved": true,
"actions": [
{
"type": "EMAIL",
"config": {
"recipients": {
"members": [
"your-email@your-org.com"
],
"orgRoles": [
"OWNER",
"MEMBER",
"BILLING_ADMIN"
],
"projectRoles": [
"OWNER",
"MEMBER"
]
}
}
},
{
"type": "SMS",
"config": {
"recipients": {
"members": [
"your-email@your-org.com"
],
"orgRoles": [
"OWNER",
"MEMBER",
"BILLING_ADMIN"
],
"projectRoles": [
"OWNER",
"MEMBER"
]
}
}
},
{
"type": "WEBHOOK",
"config": {
"url": "https://xxxx"
}
},
{
"type": "SLACK",
"config": {
"webhookUrl": "https://xxxx"
}
},
{
"type": "LARK",
"config": {
"webhookUrl": "https://xxxx"
}
},
{
"type": "WECOM",
"config": {
"webhookUrl": "https://xxxx"
}
},
{
"type": "PAGERDUTY",
"config": {
"region": "US",
"apiKey": "..."
}
},
{
"type": "OPSGENIE",
"config": {
"region": "US",
"apiKey": "..."
}
}
]
}
}