mcpField
A
alibabacloud-cms-alert-rule-create

alibabacloud-cms-alert-rule-create

github.com/aliyunCloud & DevOps281286 installsUpdated 1d ago
Repository

About alibabacloud-cms-alert-rule-create

A skill for agents creating and querying Alibaba Cloud CMS alert rules through Aliyun CLI. It routes cloud resource metrics to CMS 1.0 and Prometheus, APM, or UModel to CMS 2.0, with configuration review and confirmation before execution.

Key features

  1. 01Route requests to the CMS version
  2. 02Create and query alert rules
  3. 03Discover metrics and set conditions
  4. 04Query contacts or webhooks
  5. 05Preview and confirm before execution

Use cases

  1. 01Create alerts for cloud product metrics
  2. 02Configure alerts for Prometheus metrics
  3. 03Inspect existing APM or UModel alerts

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/aliyun/alibabacloud-aiops-skills --skill alibabacloud-cms-alert-rule-create

After installing, type/alibabacloud-cms-alert-rule-createin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

references/
apm-metrics.md
cms2-step-query.md
cms2-step1-context-lock.md
cms2-step2-query-config.md
cms2-step3-detection-config.md
cms2-step5-preview-execute.md
critical-rules.md
metrics.md
prometheus-metrics.md
ram-policies.md
step-query.md
step0-intent-routing.md
step1-context-lock.md
step2-query-generation.md
step3-detection-config.md
step4-notification.md
step5-preview-execute.md
step6-verification.md
scripts/
validate-params.sh

Details

From the project README

Alibaba Cloud Alert Rule Management

This skill creates and queries alert rules. Intent routing selects CMS 1.0 or CMS 2.0 workflow automatically.


CLI Setup (Required Before Execution)

aliyun configure ai-mode enable
aliyun configure ai-mode set-user-agent --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-cms-alert-rule-create"
aliyun plugin update

Step 0: Intent Routing

Identify user's monitoring target → route to the correct workflow. See step0-intent-routing.md.

User ScenarioRoute To
Cloud product system metrics (ECS, RDS, SLB, OSS, Redis, MongoDB…)CMS 1.0 Workflow
Prometheus / APM / UModel / custom metricsCMS 2.0 Workflow

Supported Alert Types

VersionTypeCreate APIQuery API
CMS 1.0Cloud Resource (ECS/RDS/SLB/OSS/Redis/MongoDB…)PutResourceMetricRuleDescribeMetricRuleList
CMS 2.0Prometheus (PROMETHEUS)ManageAlertRulesQueryAlertRules
CMS 2.0APM (APM)ManageAlertRulesQueryAlertRules
CMS 2.0UModel (UMODEL)ManageAlertRulesQueryAlertRules

CMS 1.0 Workflow

For query requests → step-query.md

For create requests:

StepDescriptionReference
1Context Lock — namespace, region, instancesstep1-context-lock.md
2Query Generation — discover metrics via API, match to user intentstep2-query-generation.md
3Detection Config — threshold, frequency (default 1min)step3-detection-config.md
4Notification — query contacts → select or createstep4-notification.md
5Preview & Execute — show summary → confirm → CLIstep5-preview-execute.md
6Verification — check statusstep6-verification.md

CMS 2.0 Workflow

For query requests → cms2-step-query.md

For create requests:

StepDescriptionReference
1Context Lock — build datasourceConfig (type, instanceId, region)cms2-step1-context-lock.md
2Query Config — build queryConfig (PromQL / APM measures / UModel entity)cms2-step2-query-config.md
3Detection Config — build conditionConfig (P1-P4, threshold, duration)cms2-step3-detection-config.md
4Webhook Query — call list-alert-webhooks, user selects; other types → consolecms2-step5-preview-execute.md
5Preview & Execute — show summary → confirm → manage-alert-rules CLIcms2-step5-preview-execute.md

Critical Rules

Full details → references/critical-rules.md

  1. Intent Routing — Route cloud resource metrics to CMS 1.0, Prometheus/APM/UModel to CMS 2.0. Never mix APIs.
  2. CMS 2.0 API Enforcement — CMS 2.0 alert rules MUST ONLY be created via ManageAlertRules and queried via QueryAlertRules. No other API (e.g. PutResourceMetricRule, DescribeMetricRuleList, ARMS CreateOrUpdateAlertRule, ARMS CreatePrometheusAlertRule) is permitted for CMS 2.0 alert rule creation or query. If ManageAlertRules returns error, DO NOT fallback to other APIs — report the error to user and STOP execution. CLI format: aliyun cms manage-alert-rules --body '{"action":"CREATE",...}'
  3. Contact/Webhook Query First — CMS 1.0: DescribeContactGroupList; CMS 2.0: ListAlertWebhooks is MANDATORY before alert creation. (CMS 2.0 other notification → console). DO NOT use CMS 1.0 APIs as substitute for CMS 2.0. Skipping webhook query is a critical failure.
  4. Resources Parameter — (CMS 1.0) --resources must always be explicitly passed.
  5. Workspace Required — (CMS 2.0) Must ask user for workspace value using AskUser tool. Never auto-construct (e.g. 'default', 'default-cms-{accountId}'). If AskUser fails, retry once with simplified options, then report error and STOP — do NOT proceed with fabricated values.
  6. Prometheus Required Params — (CMS 2.0) cluster_id (instanceId) + workspace MUST ASK USER using AskUser tool. Never guess, omit, or auto-select. PromQL is generated based on user-provided cluster_id + monitoring target. If AskUser fails, STOP execution.
  7. APM Required Params — (CMS 2.0) service_id (for datasourceConfig.instanceId AND queryConfig.serviceIdList) + workspace MUST ASK USER using AskUser tool. Never fabricate, use placeholders, or auto-select from discovered applications (e.g. via ListTraceApps). Discovery APIs are for reference only — final selection MUST come from user input. If AskUser fails, STOP execution.
  8. Required API Calls — Every operation must call designated APIs even if values seem known.
  9. Dynamic Metric Discovery — (CMS 1.0) MUST call describe-metric-meta-list. Use metrics.md only as fallback.
  10. CLI Timeout — --read-timeout 30 for queries, --read-timeout 60 for writes.
  11. Duplicate Pre-check — Query existing rules before creation to avoid duplicates.
  12. Mandatory Confirmation — Show config summary and get user confirmation before execution. EVEN in automated/simulated environments, you MUST output a configuration summary block and explicitly state 'Waiting for user confirmation' before proceeding. Do NOT skip this step with excuses about automation. Example format:
【配置摘要】
告警类型: APM/Prometheus
阈值: 5%
严重级别: P2
通知方式: webhook

请确认以上配置是否正确(回复确认或修改意见):
  1. User-Agent — Set ALIBABA_CLOUD_USER_AGENT="AlibabaCloud-Agent-Skills/alibabacloud-cms-alert-rule-create" for all CLI calls.
  2. Network Restriction — Never access external URLs. Use only references/ files and CLI.
  3. CLI Self-Discovery — Use --help for CLI syntax when uncertain.

Reference Files

FileScopePurpose
step0-intent-routing.mdSharedIntent routing — CMS 1.0 or CMS 2.0
step-query.mdCMS 1.0Query alert rules (DescribeMetricRuleList)
step1-context-lock.mdCMS 1.0Context lock
step2-query-generation.mdCMS 1.0Query generation & metric discovery
step3-detection-config.mdCMS 1.0Detection config
step4-notification.mdCMS 1.0Notification & contact handling
step5-preview-execute.mdCMS 1.0Preview & execute
step6-verification.mdCMS 1.0Verification
cms2-step-query.mdCMS 2.0Query alert rules (QueryAlertRules)
cms2-step1-context-lock.mdCMS 2.0Datasource config (Prometheus/APM/UModel)
cms2-step2-query-config.mdCMS 2.0Query config (PromQL, APM, UModel)
cms2-step3-detection-config.mdCMS 2.0Detection condition config (P1-P4)
cms2-step5-preview-execute.mdCMS 2.0Preview, execute & webhook query
metrics.mdCMS 1.0Common metrics quick reference (fallback)
prometheus-metrics.mdCMS 2.0Prometheus PromQL patterns
apm-metrics.mdCMS 2.0APM metrics and operators
critical-rules.mdSharedExpanded critical rule details, API tables, examples
ram-policies.mdSharedRequired RAM permissions
related_apis.yamlSharedAPI lookup before CLI calls

Cleanup (After Execution)

aliyun configure ai-mode disable

Comments

Markdown supported