alibabacloud-cms-alert-rule-create
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAlibaba 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
工作流程
| Step | Description | CMS 1.0 | Reference |
|---|---|---|---|
| 1 | Context Lock | namespace, region, instances | |
| 2 | Query Generation | Call describe-metric-meta-list to discover metrics for namespace, match to user intent | |
| 3 | Detection Config | threshold, frequency (default 1min) | |
| 4 | Notification | Query contacts → select or create | |
| 5 | Preview & Execute | Show summary → confirm → CLI | |
| 6 | Verification | Check status | |
| 步骤 | 描述 | CMS 1.0 | 参考文件 |
|---|---|---|---|
| 1 | 上下文锁定 | 命名空间、地域、实例 | |
| 2 | 查询生成 | 调用describe-metric-meta-list发现对应命名空间的指标,匹配用户意图 | |
| 3 | 检测配置 | 阈值、频率(默认1分钟) | |
| 4 | 通知配置 | 查询联系人 → 选择或创建 | |
| 5 | 预览与执行 | 展示配置摘要 → 确认 → 执行CLI命令 | |
| 6 | 验证 | 检查创建状态 | |
Pre-flight Checklist (MANDATORY)
前置检查清单(必填)
Before creating ANY alert, complete these API calls to ensure correct workflow execution.
| Step | Required API Call | CLI Command | Purpose |
|---|---|---|---|
| 1 | | | List cloud product namespaces (when product is unclear) |
| 2 | | | Metric Discovery: Get available metrics (fallback: metrics.md) |
| 4 | | | Query existing contact groups |
| 5 | | | 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 | | | 当产品不明确时,列出云产品命名空间 |
| 2 | | | 指标发现:获取可用指标(兜底方案:metrics.md) |
| 4 | | | 查询已有的联系人群组 |
| 5 | | | 创建告警规则 |
每次创建告警都需要执行这些API调用。即便看起来已经知道相关值,也始终要通过指定工具查询联系人信息。
Critical Rules
关键规则
1. Contact Query Before Create (MANDATORY)
1. 创建前先查询联系人(必填)
This step is REQUIRED and CANNOT be skipped.
- MUST call before creating any CMS alert
describe-contact-group-list - User provided contact name → Fuzzy match against existing groups
- If no match → Help user create new contact group
该步骤是必填项,不可跳过。
- 创建任何CMS告警之前必须调用
describe-contact-group-list - 用户提供联系人名称 → 与现有群组进行模糊匹配
- 如果没有匹配结果 → 协助用户创建新的联系人群组
2. Resources Parameter (MANDATORY)
2. Resources参数(必填)
Theparameter MUST always be explicitly passed. Never omit this parameter.--resources
- All resources:
--resources '[{"resource":"_ALL"}]' - Specific instances: or
--resources '[{"resource":"i-xxx"}]'--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 1 | Step 2 | Step 4 | Step 5 |
|---|---|---|---|
| | | |
| 步骤1 | 步骤2 | 步骤4 | 步骤5 |
|---|---|---|---|
| | | |
4. Contact Group Fuzzy Matching
4. 联系人群组模糊匹配
When user mentions a contact group, apply these matching rules:
| User Input | Match Strategy | Common Mappings |
|---|---|---|
| "运维组" / "ops" | Contains/keyword | → |
| "基础设施组" | Contains/keyword | → |
| "DBA团队" | Contains/keyword | → |
| "网络组" | Contains/keyword | → |
| Exact name | Direct match | Use exact name if found |
当用户提及联系人群组时,应用以下匹配规则:
| 用户输入 | 匹配策略 | 常见映射 |
|---|---|---|
| "运维组" / "ops" | 包含/关键词匹配 | → |
| "基础设施组" | 包含/关键词匹配 | → |
| "DBA团队" | 包含/关键词匹配 | → |
| "网络组" | 包含/关键词匹配 | → |
| 精确名称 | 直接匹配 | 如果找到精确匹配则直接使用 |
5. CLI Command Timeout
5. CLI命令超时设置
All CLI commands MUST be executed with a timeout to prevent hanging:
aliyun- 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.
所有 CLI命令必须设置超时时间以避免挂起:
aliyun- 默认超时:查询操作(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 and check for matching rules
describe-metric-rule-list --namespace <ns> --metric-name <metric> - 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:
- — CloudMonitor API
cms.aliyuncs.com - — ECS instance query
ecs.aliyuncs.com - — RDS instance query
rds.aliyuncs.com - — SLB instance query
slb.aliyuncs.com
No other external network access is required or permitted.
该技能仅访问阿里云OpenAPI端点。允许的域名:
- — 云监控API
cms.aliyuncs.com - — ECS实例查询
ecs.aliyuncs.com - — RDS实例查询
rds.aliyuncs.com - — SLB实例查询
slb.aliyuncs.com
不需要也不允许访问其他外部网络。
8. Dynamic Metric Discovery
8. 动态指标发现
MUST callAPI to discover metrics for the target namespace. DO NOT hardcode metric names. Usedescribe-metric-meta-listonly as fallback when API is unavailable.metrics.md
- Call to list all available namespaces (when product is unclear)
describe-project-meta - Call to get available metrics
describe-metric-meta-list --namespace <ns> - Match returned metrics to user's intent (CPU, memory, disk, network, etc.)
- Fall back to only when API call fails
metrics.md
必须调用API发现目标命名空间的指标。不要硬编码指标名称。仅当API不可用时才使用describe-metric-meta-list作为兜底方案。metrics.md
- 当产品不明确时,调用列出所有可用命名空间
describe-project-meta - 调用获取可用指标
describe-metric-meta-list --namespace <ns> - 将返回的指标与用户意图(CPU、内存、磁盘、网络等)匹配
- 仅当API调用失败时才回退到
metrics.md
9. CLI Self-Discovery
9. CLI自动发现
When unsure about CLI command syntax, arguments, or available subcommands, use to discover:
--helpbash
undefined当不确定CLI命令语法、参数或可用子命令时,使用进行查询:
--helpbash
undefinedList 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
严重程度级别
| Level | Parameter Prefix | Example |
|---|---|---|
| Critical | | |
| Warn | | |
| Info | | |
| 级别 | 参数前缀 | 示例 |
|---|---|---|
| 严重 | | |
| 警告 | | |
| 提示 | | |
Reference Files
参考文件
| File | Purpose |
|---|---|
| API lookup before CLI calls |
| Context lock |
| Query generation |
| Detection config |
| Notification |
| Preview & execute |
| Verification |
| Common metrics quick reference (fallback) |
| 文件 | 用途 |
|---|---|
| 调用CLI前的API查询参考 |
| 上下文锁定 |
| 查询生成 |
| 检测配置 |
| 通知配置 |
| 预览与执行 |
| 验证 |
| 常用指标快速参考(兜底方案) |
Prerequisites
前置条件
bash
undefinedbash
undefinedVerify 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请求头。执行任何命令前请先设置该环境变量。