alibabacloud-rds-copilot
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAlibaba Cloud RDS Copilot Intelligent Operations Assistant
阿里云RDS Copilot智能运维助手
This skill serves as an intelligent agent for Alibaba Cloud RDS Copilot in conversations, helping users with RDS-related intelligent Q&A, SQL optimization, instance operations, and troubleshooting.
本技能是对话场景下的阿里云RDS Copilot智能Agent,可帮助用户处理RDS相关的智能问答、SQL优化、实例操作以及故障排查问题。
Scenario Description
场景说明
Architecture:
Alibaba Cloud CLI + RdsAi OpenAPIMain features:
- Understand user's natural language requests (Chinese or English), identify if related to RDS Copilot
- Directly call Alibaba Cloud CLI to execute command for real-time RDS Copilot queries
aliyun rdsai chat-messages - When receiving results or user-pasted error messages, further explain, diagnose, and provide recommendations
架构:
Alibaba Cloud CLI + RdsAi OpenAPI主要功能:
- 理解用户的自然语言请求(中文或英文),识别是否与RDS Copilot相关
- 直接调用阿里云CLI执行命令,实时查询RDS Copilot
aliyun rdsai chat-messages - 收到结果或用户粘贴的报错信息时,进一步解释、诊断并提供建议
Installation
安装
Pre-check: Alibaba Cloud CLI must be installedThis skill uses Alibaba Cloud CLI to call RdsAi OpenAPI. You need to install and configure Alibaba Cloud CLI first.
预检查:必须安装阿里云CLI本技能使用阿里云CLI调用RdsAi OpenAPI,你需要先安装并配置阿里云CLI。
macOS Installation
macOS安装
bash
undefinedbash
undefinedOption 1: Install via Homebrew (recommended)
选项1:通过Homebrew安装(推荐)
brew install aliyun-cli
brew install aliyun-cli
Option 2: Install via PKG package
选项2:通过PKG安装包安装
curl -O https://aliyuncli.alicdn.com/aliyun-cli-latest.pkg
sudo installer -pkg aliyun-cli-latest.pkg -target /
curl -O https://aliyuncli.alicdn.com/aliyun-cli-latest.pkg
sudo installer -pkg aliyun-cli-latest.pkg -target /
Option 3: Install via one-click script
选项3:通过一键脚本安装
/bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/install.sh)"
undefined/bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/install.sh)"
undefinedLinux Installation
Linux安装
bash
undefinedbash
undefinedInstall via one-click script
通过一键脚本安装
/bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/install.sh)"
/bin/bash -c "$(curl -fsSL https://aliyuncli.alicdn.com/install.sh)"
Or download TGZ package for manual installation
或者下载TGZ包手动安装
curl https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz -o aliyun-cli.tgz
tar xzvf aliyun-cli.tgz
sudo mv aliyun /usr/local/bin/
undefinedcurl https://aliyuncli.alicdn.com/aliyun-cli-linux-latest-amd64.tgz -o aliyun-cli.tgz
tar xzvf aliyun-cli.tgz
sudo mv aliyun /usr/local/bin/
undefinedVerify Installation
验证安装
bash
aliyun versionbash
aliyun versionCredential Configuration
凭证配置
Option 1: Interactive Configuration (Recommended)
选项1:交互式配置(推荐)
bash
aliyun configure --profile rdsaiFollow the prompts to enter:
- Access Key Id: Your AccessKey ID
- Access Key Secret: Your AccessKey Secret
- Default Region Id: cn-hangzhou (or other regions)
bash
aliyun configure --profile rdsai按照提示输入:
- Access Key Id:你的AccessKey ID
- Access Key Secret:你的AccessKey Secret
- Default Region Id:cn-hangzhou(或其他区域)
Option 2: Non-interactive Configuration
选项2:非交互式配置
bash
aliyun configure set \
--profile rdsai \
--mode AK \
--access-key-id <yourAccessKeyID> \
--access-key-secret <yourAccessKeySecret> \
--region cn-hangzhoubash
aliyun configure set \
--profile rdsai \
--mode AK \
--access-key-id <yourAccessKeyID> \
--access-key-secret <yourAccessKeySecret> \
--region cn-hangzhouCommand Format
命令格式
Basic Command Structure
基础命令结构
bash
aliyun rdsai chat-messages \
--query '<query content>' \
--inputs RegionId=<region ID> Language=<language> Timezone=<timezone> [CustomAgentId=<custom agent ID>] \
--event-mode separate \
--endpoint rdsai.aliyuncs.com \
--user-agent 'AlibabaCloud-Agent-Skills' \
[--conversation-id '<conversation ID>']bash
aliyun rdsai chat-messages \
--query '<query content>' \
--inputs RegionId=<region ID> Language=<language> Timezone=<timezone> [CustomAgentId=<custom agent ID>] \
--event-mode separate \
--endpoint rdsai.aliyuncs.com \
--user-agent 'AlibabaCloud-Agent-Skills' \
[--conversation-id '<conversation ID>']Parameter Description
参数说明
IMPORTANT: Parameter Confirmation — Before executing any command, Determine user intent: SQL writing/optimization, SQL diagnosis, instance parameter tuning, troubleshooting, performance analysis, query instance list, etc. Collect necessary parameters (use default values if not specified).
| Parameter | Required/Optional | Description | Default |
|---|---|---|---|
| Required | User query content | - |
| Optional | Alibaba Cloud region ID | |
| Optional | Language | |
| Optional | Timezone | |
| Optional | Custom Agent ID | None |
| Optional | Event mode | |
| Required | API endpoint | |
| Optional | Conversation ID for multi-turn dialogue | None |
| Optional | Region for API call | Credential default region |
| Optional | Specify credential profile name | Default profile |
| Required | Custom User-Agent | |
重要提示:参数确认 — 执行任何命令前, 明确用户意图:SQL编写/优化、SQL诊断、实例参数调优、故障排查、性能分析、查询实例列表等。 收集必要参数(未指定时使用默认值)。
| 参数 | 必填/可选 | 说明 | 默认值 |
|---|---|---|---|
| 必填 | 用户查询内容 | - |
| 可选 | 阿里云区域ID | |
| 可选 | 语言 | |
| 可选 | 时区 | |
| 可选 | 自定义Agent ID | 无 |
| 可选 | 事件模式 | |
| 必填 | API endpoint | |
| 可选 | 多轮对话的会话ID | 无 |
| 可选 | API调用的区域 | 凭证默认区域 |
| 可选 | 指定凭证配置名称 | 默认配置 |
| 必填 | 自定义User-Agent | |
RAM Permissions
RAM权限
This skill requires the following RAM permissions. See references/ram-policies.md for details.
| Permission | Description |
|---|---|
| Call RDS AI Assistant API |
本技能需要以下RAM权限。详情查看references/ram-policies.md。
| 权限 | 说明 |
|---|---|
| 调用RDS AI助手API |
Core Workflow
核心工作流程
1. Confirm Task Type and Parameters
1. 确认任务类型和参数
Determine user intent: SQL writing/optimization, SQL diagnosis, instance parameter tuning, troubleshooting, performance analysis, query instance list, etc.
Collect necessary parameters (use default values if not specified):
- : Region ID (default
RegionId)cn-hangzhou - : Language (default
Language)zh-CN - : Timezone (default
Timezone)Asia/Shanghai - : Custom Agent ID (optional)
CustomAgentId - : Conversation ID for multi-turn dialogue (optional)
--conversation-id
明确用户意图:SQL编写/优化、SQL诊断、实例参数调优、故障排查、性能分析、查询实例列表等。
收集必要参数(未指定时使用默认值):
- :区域ID(默认
RegionId)cn-hangzhou - :语言(默认
Language)zh-CN - :时区(默认
Timezone)Asia/Shanghai - :自定义Agent ID(可选)
CustomAgentId - :多轮对话的会话ID(可选)
--conversation-id
2. Construct Command and Call CLI
2. 构建命令并调用CLI
bash
undefinedbash
undefinedBasic query
基础查询
aliyun rdsai chat-messages
--query 'List RDS MySQL instances in Hangzhou region'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
--query 'List RDS MySQL instances in Hangzhou region'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
aliyun rdsai chat-messages
--query 'List RDS MySQL instances in Hangzhou region'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
--query 'List RDS MySQL instances in Hangzhou region'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
Troubleshooting example
故障排查示例
aliyun rdsai chat-messages
--query 'RDS instance rm-bp1xxx connection timeout, error Too many connections, please help troubleshoot. Instance is in Hangzhou region.'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
--query 'RDS instance rm-bp1xxx connection timeout, error Too many connections, please help troubleshoot. Instance is in Hangzhou region.'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
aliyun rdsai chat-messages
--query 'RDS instance rm-bp1xxx connection timeout, error Too many connections, please help troubleshoot. Instance is in Hangzhou region.'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
--query 'RDS instance rm-bp1xxx connection timeout, error Too many connections, please help troubleshoot. Instance is in Hangzhou region.'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
Query with Beijing region
北京区域查询
aliyun rdsai chat-messages
--query 'Optimize this SQL: SELECT * FROM users WHERE name LIKE "%test%"'
--inputs RegionId=cn-beijing Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
--query 'Optimize this SQL: SELECT * FROM users WHERE name LIKE "%test%"'
--inputs RegionId=cn-beijing Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
aliyun rdsai chat-messages
--query 'Optimize this SQL: SELECT * FROM users WHERE name LIKE "%test%"'
--inputs RegionId=cn-beijing Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
--query 'Optimize this SQL: SELECT * FROM users WHERE name LIKE "%test%"'
--inputs RegionId=cn-beijing Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
Multi-turn dialogue (using ConversationId from previous response)
多轮对话(使用上一次返回的ConversationId)
aliyun rdsai chat-messages
--query 'Continue analyzing the above issue'
--conversation-id '<ConversationId from previous response>'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
--query 'Continue analyzing the above issue'
--conversation-id '<ConversationId from previous response>'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
aliyun rdsai chat-messages
--query 'Continue analyzing the above issue'
--conversation-id '<ConversationId from previous response>'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
--query 'Continue analyzing the above issue'
--conversation-id '<ConversationId from previous response>'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
Using custom Agent
使用自定义Agent
aliyun rdsai chat-messages
--query 'Analyze database performance'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai CustomAgentId=your-custom-agent-id
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
--query 'Analyze database performance'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai CustomAgentId=your-custom-agent-id
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
undefinedaliyun rdsai chat-messages
--query 'Analyze database performance'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai CustomAgentId=your-custom-agent-id
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
--query 'Analyze database performance'
--inputs RegionId=cn-hangzhou Language=zh-CN Timezone=Asia/Shanghai CustomAgentId=your-custom-agent-id
--event-mode separate
--endpoint rdsai.aliyuncs.com
--user-agent 'AlibabaCloud-Agent-Skills'
undefined3. Parse Results and Follow-up Processing
3. 解析结果与后续处理
- Explain RDS Copilot's response to the user in natural language
- If the response contains SQL or operational steps, assess risks and warn:
- Avoid executing high-risk statements directly in production (e.g., large table /
DELETE/ schema changes)UPDATE - Recommend validating in test environment or adding backup/condition restrictions
- Avoid executing high-risk statements directly in production (e.g., large table
- If continuing the conversation, record the from the response for the next query
ConversationId
- 用自然语言向用户解释RDS Copilot的响应
- 如果响应包含SQL或操作步骤,评估风险并给出警告:
- 避免直接在生产环境执行高危语句(例如大表/
DELETE/结构变更)UPDATE - 建议在测试环境验证或添加备份/条件限制
- 避免直接在生产环境执行高危语句(例如大表
- 如果需要继续对话,记录响应中的用于下一次查询
ConversationId
Output Format
输出格式
Alibaba Cloud CLI returns JSON format responses (streaming multiple JSON events):
json
{"data":{"ConversationId":"8227be22-xxxx-xxxx-xxxx-xxxxxxxxxxxx","Event":"workflow_started","MessageId":"a79c881c-xxxx-xxxx-xxxx-xxxxxxxxxxxx",...}}
{"data":{"Answer":"<partial answer content>","Event":"message",...}}
{"data":{"Event":"workflow_finished",...}}Key fields:
- : Conversation ID (for multi-turn dialogue)
ConversationId - : AI assistant's response content
Answer - : Event type (workflow_started, message, workflow_finished)
Event
阿里云CLI返回JSON格式响应(流式返回多个JSON事件):
json
{"data":{"ConversationId":"8227be22-xxxx-xxxx-xxxx-xxxxxxxxxxxx","Event":"workflow_started","MessageId":"a79c881c-xxxx-xxxx-xxxx-xxxxxxxxxxxx",...}}
{"data":{"Answer":"<partial answer content>","Event":"message",...}}
{"data":{"Event":"workflow_finished",...}}关键字段:
- :会话ID(用于多轮对话)
ConversationId - :AI助手的响应内容
Answer - :事件类型(workflow_started、message、workflow_finished)
Event
Success Verification
成功验证
- CLI installation successful: shows version number
aliyun version - Credential configured correctly: shows configured credentials
aliyun configure list - API call successful: Response contains and
ConversationIdin JSON formatAnswer - Response content valid: Answer is relevant to the query content
See references/verification-method.md for detailed verification steps.
- CLI安装成功:返回版本号
aliyun version - 凭证配置正确:显示已配置的凭证
aliyun configure list - API调用成功:响应中包含JSON格式的和
ConversationIdAnswer - 响应内容有效:回答与查询内容相关
详细验证步骤查看references/verification-method.md。
Cleanup
清理
This skill only performs read-only query operations, does not create any cloud resources, no cleanup required.
本技能仅执行只读查询操作,不会创建任何云资源,无需清理。
API and Command List
API和命令列表
See references/related-apis.md for details.
| Product | API Action | CLI Command | Description |
|---|---|---|---|
| RdsAi | ChatMessages | | RDS AI Assistant dialogue API |
详情查看references/related-apis.md。
| 产品 | API Action | CLI命令 | 说明 |
|---|---|---|---|
| RdsAi | ChatMessages | | RDS AI助手对话API |
Best Practices
最佳实践
- Use multi-turn dialogue: For complex issues, use for context-aware multi-turn conversations
--conversation-id - Specify correct region: Set parameter based on the RDS instance's region
RegionId - Be cautious in production: SQL recommendations from RDS Copilot should be validated in test environment first
- Save conversation ID: Save the returned if you need to follow up or continue analysis
ConversationId - Use configuration file: Recommend using to configure credentials, avoid exposing sensitive information in command line
aliyun configure - Use --profile: You can configure multiple credential profiles and switch between accounts using
--profile
- 使用多轮对话:针对复杂问题,使用实现带上下文的多轮对话
--conversation-id - 指定正确区域:根据RDS实例所在区域设置参数
RegionId - 生产环境谨慎操作:RDS Copilot给出的SQL建议需要先在测试环境验证
- 保存会话ID:如果需要跟进或继续分析,保存返回的
ConversationId - 使用配置文件:推荐使用配置凭证,避免在命令行暴露敏感信息
aliyun configure - 使用--profile参数:可以配置多个凭证配置,通过在不同账号间切换
--profile
Reference Links
参考链接
| Reference Document | Description |
|---|---|
| Alibaba Cloud CLI Documentation | Alibaba Cloud CLI User Guide |
| references/related-apis.md | API and Command List |
| references/ram-policies.md | RAM Policy Configuration |
| references/verification-method.md | Verification Methods |
| references/acceptance-criteria.md | Acceptance Criteria |
| 参考文档 | 说明 |
|---|---|
| 阿里云CLI文档 | 阿里云CLI用户指南 |
| references/related-apis.md | API和命令列表 |
| references/ram-policies.md | RAM策略配置 |
| references/verification-method.md | 验证方法 |
| references/acceptance-criteria.md | 验收标准 |