alibabacloud-cms-alert-rule-create

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Alibaba Cloud Alert Rule Creation

阿里云告警规则创建

This skill creates CMS 1.0 alert rules for cloud resource monitoring using CloudMonitor metrics. Supports all CMS-integrated cloud products through dynamic metric discovery.

该技能使用CloudMonitor指标创建用于云资源监控的CMS 1.0告警规则。通过动态指标发现支持所有接入CMS的云产品

Workflow

工作流程

StepDescriptionCMS 1.0Reference
1Context Locknamespace, region, instances
step1-context-lock.md
2Query GenerationCall describe-metric-meta-list to discover metrics for namespace, match to user intent
step2-query-generation.md
3Detection Configthreshold, frequency (default 1min)
step3-detection-config.md
4NotificationQuery contacts → select or create
step4-notification.md
5Preview & ExecuteShow summary → confirm → CLI
step5-preview-execute.md
6VerificationCheck status
step6-verification.md

步骤描述CMS 1.0参考文件
1上下文锁定命名空间、地域、实例
step1-context-lock.md
2查询生成调用describe-metric-meta-list发现对应命名空间的指标,匹配用户意图
step2-query-generation.md
3检测配置阈值、频率(默认1分钟)
step3-detection-config.md
4通知配置查询联系人 → 选择或创建
step4-notification.md
5预览与执行展示配置摘要 → 确认 → 执行CLI命令
step5-preview-execute.md
6验证检查创建状态
step6-verification.md

Pre-flight Checklist (MANDATORY)

前置检查清单(必填)

Before creating ANY alert, complete these API calls to ensure correct workflow execution.
StepRequired API CallCLI CommandPurpose
1
DescribeProjectMeta
aliyun cms describe-project-meta
List cloud product namespaces (when product is unclear)
2
DescribeMetricMetaList
aliyun cms describe-metric-meta-list --namespace <ns>
Metric Discovery: Get available metrics (fallback: metrics.md)
4
DescribeContactGroupList
aliyun cms describe-contact-group-list
Query existing contact groups
5
PutResourceMetricRule
aliyun cms put-resource-metric-rule ...
Create the alert rule
These API calls are required for every alert creation. Always query contacts via the designated tools, even if the values seem known.

创建任何告警之前,请完成以下API调用以确保工作流程正确执行。
步骤所需API调用CLI命令用途
1
DescribeProjectMeta
aliyun cms describe-project-meta
当产品不明确时,列出云产品命名空间
2
DescribeMetricMetaList
aliyun cms describe-metric-meta-list --namespace <ns>
指标发现:获取可用指标(兜底方案:metrics.md)
4
DescribeContactGroupList
aliyun cms describe-contact-group-list
查询已有的联系人群组
5
PutResourceMetricRule
aliyun cms put-resource-metric-rule ...
创建告警规则
每次创建告警都需要执行这些API调用。即便看起来已经知道相关值,也始终要通过指定工具查询联系人信息。

Critical Rules

关键规则

1. Contact Query Before Create (MANDATORY)

1. 创建前先查询联系人(必填)

This step is REQUIRED and CANNOT be skipped.
  1. MUST call
    describe-contact-group-list
    before creating any CMS alert
  2. User provided contact name → Fuzzy match against existing groups
  3. If no match → Help user create new contact group
该步骤是必填项,不可跳过。
  1. 创建任何CMS告警之前必须调用
    describe-contact-group-list
  2. 用户提供联系人名称 → 与现有群组进行模糊匹配
  3. 如果没有匹配结果 → 协助用户创建新的联系人群组

2. Resources Parameter (MANDATORY)

2. Resources参数(必填)

The
--resources
parameter MUST always be explicitly passed. Never omit this parameter.
  • All resources:
    --resources '[{"resource":"_ALL"}]'
  • Specific instances:
    --resources '[{"resource":"i-xxx"}]'
    or
    --resources '[{"resource":"i-xxx"},{"resource":"i-yyy"}]'
This applies to ALL products (ECS, RDS, SLB, OSS, MongoDB, etc.).
必须始终显式传入
--resources
参数,不得省略该参数。
  • 全部资源
    --resources '[{"resource":"_ALL"}]'
  • 指定实例
    --resources '[{"resource":"i-xxx"}]'
    --resources '[{"resource":"i-xxx"},{"resource":"i-yyy"}]'
该规则适用于所有产品(ECS、RDS、SLB、OSS、MongoDB等)。

3. Required API Calls Summary

3. 必要API调用汇总

Step 1Step 2Step 4Step 5
describe-project-meta
(when product unclear)
describe-metric-meta-list
(MANDATORY)
describe-contact-group-list
(MANDATORY)
put-resource-metric-rule
步骤1步骤2步骤4步骤5
describe-project-meta
(产品不明确时调用)
describe-metric-meta-list
(必填)
describe-contact-group-list
(必填)
put-resource-metric-rule

4. Contact Group Fuzzy Matching

4. 联系人群组模糊匹配

When user mentions a contact group, apply these matching rules:
User InputMatch StrategyCommon Mappings
"运维组" / "ops"Contains/keyword
运维组
,
ops-alert-group
,
SRE-Team
"基础设施组"Contains/keyword
infrastructure
,
infrastructure-team
"DBA团队"Contains/keyword
DBA-Alert-Group
,
dba-team
"网络组"Contains/keyword
network-ops
,
network-sre
Exact nameDirect matchUse exact name if found
当用户提及联系人群组时,应用以下匹配规则:
用户输入匹配策略常见映射
"运维组" / "ops"包含/关键词匹配
运维组
,
ops-alert-group
,
SRE-Team
"基础设施组"包含/关键词匹配
infrastructure
,
infrastructure-team
"DBA团队"包含/关键词匹配
DBA-Alert-Group
,
dba-team
"网络组"包含/关键词匹配
network-ops
,
network-sre
精确名称直接匹配如果找到精确匹配则直接使用

5. CLI Command Timeout

5. CLI命令超时设置

All
aliyun
CLI commands MUST be executed with a timeout to prevent hanging:
  • Default timeout: 30 seconds for query operations (describe/list/get)
  • Extended timeout: 60 seconds for write operations (put/create/update)
  • If a command does not return within the timeout, retry once before reporting failure.
所有
aliyun
CLI命令必须设置超时时间以避免挂起:
  • 默认超时:查询操作(describe/list/get)30秒
  • 延长超时:写操作(put/create/update)60秒
  • 如果命令在超时时间内未返回,先重试一次再上报失败。

6. Duplicate Alert Pre-check

6. 重复告警预检查

Before creating an alert rule, check if a rule with the same configuration already exists:
  • Call
    describe-metric-rule-list --namespace <ns> --metric-name <metric>
    and check for matching rules
  • If a duplicate exists, inform the user and ask whether to skip or create with a new name
创建告警规则之前,检查是否已存在相同配置的规则:
  • 调用
    describe-metric-rule-list --namespace <ns> --metric-name <metric>
    检查匹配的规则
  • 如果存在重复,告知用户并询问是跳过还是使用新名称创建

7. Network Access Restriction

7. 网络访问限制

This skill only accesses Alibaba Cloud OpenAPI endpoints. Allowed domains:
  • cms.aliyuncs.com
    — CloudMonitor API
  • ecs.aliyuncs.com
    — ECS instance query
  • rds.aliyuncs.com
    — RDS instance query
  • slb.aliyuncs.com
    — SLB instance query
No other external network access is required or permitted.
该技能仅访问阿里云OpenAPI端点。允许的域名:
  • cms.aliyuncs.com
    — 云监控API
  • ecs.aliyuncs.com
    — ECS实例查询
  • rds.aliyuncs.com
    — RDS实例查询
  • slb.aliyuncs.com
    — SLB实例查询
不需要也不允许访问其他外部网络。

8. Dynamic Metric Discovery

8. 动态指标发现

MUST call
describe-metric-meta-list
API to discover metrics for the target namespace. DO NOT hardcode metric names. Use
metrics.md
only as fallback when API is unavailable.
  1. Call
    describe-project-meta
    to list all available namespaces (when product is unclear)
  2. Call
    describe-metric-meta-list --namespace <ns>
    to get available metrics
  3. Match returned metrics to user's intent (CPU, memory, disk, network, etc.)
  4. Fall back to
    metrics.md
    only when API call fails
必须调用
describe-metric-meta-list
API发现目标命名空间的指标。不要硬编码指标名称。仅当API不可用时才使用
metrics.md
作为兜底方案。
  1. 当产品不明确时,调用
    describe-project-meta
    列出所有可用命名空间
  2. 调用
    describe-metric-meta-list --namespace <ns>
    获取可用指标
  3. 将返回的指标与用户意图(CPU、内存、磁盘、网络等)匹配
  4. 仅当API调用失败时才回退到
    metrics.md

9. CLI Self-Discovery

9. CLI自动发现

When unsure about CLI command syntax, arguments, or available subcommands, use
--help
to discover:
bash
undefined
当不确定CLI命令语法、参数或可用子命令时,使用
--help
进行查询:
bash
undefined

List all available CMS commands

列出所有可用的CMS命令

aliyun cms --help
aliyun cms --help

Show detailed usage for a specific command

展示特定命令的详细用法

aliyun cms <command> --help
aliyun cms <command> --help

Example:

示例:

aliyun cms describe-metric-meta-list --help

This is the preferred way to resolve CLI uncertainties rather than guessing parameters.
aliyun cms describe-metric-meta-list --help

这是解决CLI使用疑问的首选方式,不要猜测参数。

10. Mandatory Confirmation Before Execution

10. 执行前强制确认

MUST present configuration summary and get explicit user confirmation BEFORE calling
PutResourceMetricRule
.
Even if all parameters are clear, DO NOT execute directly. Always show a configuration summary including: Product, Metric, Threshold, Severity, Resources scope, and Contact Group. Wait for user's explicit "Yes" or confirmation before proceeding.

调用
PutResourceMetricRule
之前,必须展示配置摘要并获得用户明确确认。
即便所有参数都清晰,也不要直接执行。始终展示配置摘要,包括:产品、指标、阈值、严重程度、资源范围和联系人群组。等待用户明确回复“是”或确认后再继续。

Severity Levels

严重程度级别

LevelParameter PrefixExample
Critical
--escalations-critical-*
--escalations-critical-threshold 85
Warn
--escalations-warn-*
--escalations-warn-threshold 99.9
Info
--escalations-info-*
--escalations-info-threshold 50

级别参数前缀示例
严重
--escalations-critical-*
--escalations-critical-threshold 85
警告
--escalations-warn-*
--escalations-warn-threshold 99.9
提示
--escalations-info-*
--escalations-info-threshold 50

Reference Files

参考文件

FilePurpose
related_apis.yaml
API lookup before CLI calls
references/step1-context-lock.md
Context lock
references/step2-query-generation.md
Query generation
references/step3-detection-config.md
Detection config
references/step4-notification.md
Notification
references/step5-preview-execute.md
Preview & execute
references/step6-verification.md
Verification
references/metrics.md
Common metrics quick reference (fallback)

文件用途
related_apis.yaml
调用CLI前的API查询参考
references/step1-context-lock.md
上下文锁定
references/step2-query-generation.md
查询生成
references/step3-detection-config.md
检测配置
references/step4-notification.md
通知配置
references/step5-preview-execute.md
预览与执行
references/step6-verification.md
验证
references/metrics.md
常用指标快速参考(兜底方案)

Prerequisites

前置条件

bash
undefined
bash
undefined

Verify aliyun CLI is configured

验证aliyun CLI已配置

aliyun configure get
aliyun configure get

Set User-Agent for all CLI calls (REQUIRED)

为所有CLI调用设置User-Agent(必填)

export ALIBABA_CLOUD_USER_AGENT="AlibabaCloud-Agent-Skills"

**Important**: All `aliyun` CLI calls in this skill MUST include the User-Agent header. Set the environment variable before executing any commands.
export ALIBABA_CLOUD_USER_AGENT="AlibabaCloud-Agent-Skills"

**重要提示**:该技能中所有`aliyun` CLI调用都必须包含User-Agent请求头。执行任何命令前请先设置该环境变量。