跳到主要内容

更新告警规则 (V2)

本接口通过 ID 更新现有的告警规则。当前用户须为项目管理员。

PUT/v2/alertRules/{ALERT_RULE_ID}
连接端点

该 API 的 Base URL 格式如下:

https://api.cloud.zilliz.com

📘说明

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

shell
export BASE_URL="https://api.cloud.zilliz.com"
参数
Authorizationstringheader必填项

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

示例值:Bearer {{TOKEN}}
ALERT_RULE_IDstringpath必填项

要更新的告警规则 ID。

示例值:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
请求体
ruleNamestring

告警规则名称。

levelstring必填项

告警规则级别。

metricNamestring必填项

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

thresholdstring

告警规则阈值。

windowSizestring

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

enabledboolean必填项

告警规则是否启用。

sendResolvedboolean必填项

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

actionsarray必填项

触发告警规则时采取的操作列表。

[]actionsobject必填项

触发告警规则时采取的操作。

typestring必填项

操作类型。

configobject必填项

操作配置。

comparisonMethodstring必填项

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

targetInstanceIdsarray

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

[]targetInstanceIdsstring

集群 ID。

metricUnitstring

指标单位(如 "bytes"、"percent")。

repeatIntervalSecondsinteger<int32>

重复告警通知的间隔时间(秒)。

bash
export TOKEN="YOUR_API_KEY"
export ALERT_RULE_ID="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

curl --request PUT \
--url "${BASE_URL}/v2/alertRules/${ALERT_RULE_ID}" \
--header "Authorization: Bearer ${TOKEN}" \
--header "Request-Timeout: 5" \
--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",
"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": "..."
}
}
],
"comparisonMethod": "GREATER_THAN"
}'
响应

返回指定项目的所有告警规则列表。

返回告警规则列表。

codeinteger<int32>

响应码。

dataobject

告警规则更新操作返回的响应负载对象。

idstring

告警规则 ID。

orgIdstring

该告警规则所属组织的 ID。

projectIdstring

告警规则所属项目 ID。

enabledboolean

告警规则是否启用。

sendResolvedboolean

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

levelstring

告警规则级别。

ruleNamestring

告警规则名称。

metricNamestring

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

metricUnitstring

被监控指标的单位。

windowSizestring

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

thresholdstring

告警规则阈值。

comparisonMethodstring

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

targetInstanceIdsarray

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

[]targetInstanceIdsstring

集群 ID。

actionsarray

触发告警规则时采取的操作列表。

[]actionsobject

触发告警规则时采取的操作。

typestring必填项

操作类型。

configobject必填项

操作配置。

repeatIntervalSecondsinteger<int32>

告警通知的重复间隔(秒)。

返回错误消息。

codeinteger

响应码。

messagestring

错误描述。

Successjson
{
"code": 0,
"data": {
"id": "12391290837zs09sad0d09123",
"projectId": "proj-b44a39b0c51cf21791a841",
"ruleName": "my alert name",
"level": "CRITICAL",
"metricName": "REQUEST_LATENCY_SEARCH_P99",
"threshold": "70",
"windowSize": "10",
"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": "..."
}
}
],
"comparisonMethod": "GREATER_THAN",
"targetInstanceIds": [
"in01-xxxxxxxxxxxx"
]
}
}