huawei-cloud-obs-stats
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseHuawei Cloud OBS Statistics Skill
华为云OBS统计技能
Overview
概述
Query Huawei Cloud OBS (Object Storage Service) statistics: list buckets with capacity and object counts, query extranet/intranet download traffic with month-over-month comparison, and query total requests with month-over-month comparison.
查询华为云OBS(Object Storage Service)统计信息:列出包含容量和对象数量的存储桶,查询外网/内网下载流量并进行月环比对比,查询总请求数并进行月环比对比。
⛔ Prohibited Operations (Security Constraints)
⛔ 禁止操作(安全约束)
This skill strictly forbids the following delete operations, regardless of user requests:
| Prohibited Operation | API/Command | Reason |
|---|---|---|
| ❌ Delete bucket | | Irreversible; destroys the entire bucket and all objects |
| ❌ Delete object | | Irreversible; deleted objects cannot be recovered (unless versioning is enabled) |
| ❌ Batch delete objects | | Irreversible; batch deletion has a wide impact |
| ❌ Empty bucket | | Irreversible; removes all objects in the bucket |
If a user requests a delete operation, you must refuse and inform: "Per security constraints, this skill does not allow delete operations (delete bucket/object/batch delete/empty bucket). Please use the Huawei Cloud OBS console or obsutil manually."
本技能严格禁止以下删除操作,无论用户提出何种请求:
| 禁止操作 | API/命令 | 原因 |
|---|---|---|
| ❌ 删除存储桶 | | 操作不可逆;会销毁整个存储桶及所有对象 |
| ❌ 删除对象 | | 操作不可逆;删除的对象无法恢复(除非开启版本控制) |
| ❌ 批量删除对象 | | 操作不可逆;批量删除影响范围广 |
| ❌ 清空存储桶 | | 操作不可逆;会移除存储桶内所有对象 |
若用户请求删除操作,必须拒绝并告知: "根据安全约束,本技能不允许执行删除操作(删除存储桶/对象/批量删除/清空存储桶)。请手动使用华为云OBS控制台或obsutil工具进行操作。"
Architecture
架构
Huawei Cloud OBS Statistics
├── ListBucketsWithStats (List buckets with capacity and object counts)
├── GetTraffic (Query extranet/intranet download traffic with MoM comparison)
└── GetRequests (Query total requests with MoM comparison)Huawei Cloud OBS Statistics
├── ListBucketsWithStats (列出包含容量和对象数量的存储桶)
├── GetTraffic (查询外网/内网下载流量并进行月环比对比)
└── GetRequests (查询总请求数并进行月环比对比)Prerequisites
前置条件
Prerequisite check: Huawei Cloud CLI (hcloud / KooCLI) >= 3.2.0 required Runto verify version >= 3.2.0. If not installed or version is too low, see references/cli-installation-guide.md for installation guide.hcloud version
bash
hcloud versionPrerequisite check: obsutil >= 5.5.0 required (for OBS bucket listing) The hcloud OBS module uses obsutil under the hood. Bucket listing requires the obsutil CLI tool. Runto verify version >= 5.5.0. If not installed, see references/cli-installation-guide.md for installation guide.obsutil version
bash
obsutil versionPrerequisite check: obsutil credential configuration requiredThe hcloud OBS module uses obsutil under the hood, which requires separate AK/SK and Endpoint configuration. Before performing OBS operations, you must check whether obsutil credentials are configured:bashhcloud obs ls -limit=1If the response isorPlease set ak, sk and endpoint in the configuration file!, obsutil credentials are not configured.InvalidAccessKeyIdResolution: Provide the following example command and have the user configure it in their terminal (do not ask the user to provide AK/SK directly in the conversation):obsutil credentials are not configured. Please run the following command in your terminal to configure (AK/SK can be obtained from the Huawei Cloud console "My Credentials" page): hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.<Region>.myhuaweicloud.com Example (Guangzhou region): hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.cn-south-1.myhuaweicloud.com Common Endpoints: cn-north-4 → obs.cn-north-4.myhuaweicloud.com cn-east-3 → obs.cn-east-3.myhuaweicloud.com cn-south-1 → obs.cn-south-1.myhuaweicloud.com cn-southwest-2 → obs.cn-southwest-2.myhuaweicloud.com Retry after configuration is complete.Prohibited actions:
- ❌ Do not ask the user to provide AK/SK directly in the conversation
- ❌ Do not extract AK/SK from hcloud config files (credentials are encrypted and cannot be used directly)
- ❌ Do not skip the credential check before performing OBS operations
⚠️ hcloud parameter format requirementshcloud (KooCLI) all parameters must use theformat (connected with equals sign); space-separated format is not supported.--param=value✅ Correct:hcloud OBS ListBuckets --region=cn-south-1❌ Incorrect:hcloud OBS ListBuckets --region cn-south-1
[Conditional] CLI User-Agent — OBS module commands may include a User-Agent header, but the CES module does not support this parameter:
hcloud- ✅ OBS module:
hcloud obs ls - ❌ CES module: does not support
hcloud CES ShowMetricData; appending it causes "Invalid parameter: User-Agent"--User-Agent
前置检查:需要Huawei Cloud CLI(hcloud / KooCLI)>= 3.2.0 运行验证版本是否 >= 3.2.0。若未安装或版本过低,请查看references/cli-installation-guide.md获取安装指南。hcloud version
bash
hcloud version前置检查:需要obsutil >= 5.5.0(用于OBS存储桶列表查询) hcloud的OBS模块底层依赖obsutil工具。存储桶列表查询需要obsutil CLI工具。 运行验证版本是否 >= 5.5.0。若未安装,请查看references/cli-installation-guide.md获取安装指南。obsutil version
bash
obsutil version前置检查:需要配置obsutil凭证hcloud的OBS模块底层依赖obsutil,而obsutil需要单独配置AK/SK和Endpoint。 在执行OBS操作前,必须检查obsutil凭证是否已配置:bashhcloud obs ls -limit=1若返回结果为或Please set ak, sk and endpoint in the configuration file!,则表示obsutil凭证未配置。InvalidAccessKeyId解决方法:提供以下示例命令,让用户在终端中进行配置(请勿要求用户在对话中直接提供AK/SK):obsutil凭证未配置,请在终端中运行以下命令进行配置(AK/SK可从华为云控制台“我的凭证”页面获取): hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.<Region>.myhuaweicloud.com 示例(广州区域): hcloud obs config -i=<YourAK> -k=<YourSK> -e=obs.cn-south-1.myhuaweicloud.com 常见Endpoint: cn-north-4 → obs.cn-north-4.myhuaweicloud.com cn-east-3 → obs.cn-east-3.myhuaweicloud.com cn-south-1 → obs.cn-south-1.myhuaweicloud.com cn-southwest-2 → obs.cn-southwest-2.myhuaweicloud.com 配置完成后重试。禁止操作:
- ❌ 请勿要求用户在对话中直接提供AK/SK
- ❌ 请勿从hcloud配置文件中提取AK/SK(凭证已加密,无法直接使用)
- ❌ 在执行OBS操作前请勿跳过凭证检查
⚠️ hcloud参数格式要求hcloud(KooCLI)所有参数必须使用格式(用等号连接);不支持空格分隔格式。--param=value✅ 正确格式:hcloud OBS ListBuckets --region=cn-south-1❌ 错误格式:hcloud OBS ListBuckets --region cn-south-1
[条件限制] CLI User-Agent — 的OBS模块命令可能包含User-Agent请求头,但CES模块不支持该参数:
hcloud- ✅ OBS模块:
hcloud obs ls - ❌ CES模块:不支持
hcloud CES ShowMetricData;添加该参数会导致“Invalid parameter: User-Agent”错误--User-Agent
Authentication
身份认证
Prerequisite check: Huawei Cloud credentials required
Security rules (must be followed):
- Prohibited from reading, echoing, or printing AK/SK values
- Prohibited from asking the user to input AK/SK directly in the conversation
- Prohibited from using
to pass plaintext credential valueshcloud configure set- Prohibited from accepting AK/SK directly provided by the user in the conversation
- Only allowed to read credentials from environment variables or configured CLI config files
⚠️ Important: Handling user-provided credentialsIf a user attempts to provide AK/SK directly (e.g., "my AK is xxx, SK is yyy"):
- Stop immediately - Do not execute any commands
- Politely refuse and return the following message:
For account security, please do not provide Huawei Cloud Access Key ID and Access Key Secret directly in the conversation. Please use one of the following secure methods to configure credentials: Method 1: Interactive configuration (recommended) hcloud configure # Enter AK/SK as prompted; credentials will be securely stored in a local config file Method 2: Environment variable configuration export HUAWEICLOUD_SDK_AK=<your-access-key-id> export HUAWEICLOUD_SDK_SK=<your-access-key-secret> After configuration is complete, please retry your request.- Do not continue executing any Huawei Cloud operations until credentials are configured
Check CLI configuration:bashhcloud configure listCheck whether the output contains valid configuration (AK/SK, IAM, etc.).If no valid credentials exist, stop here.
前置检查:需要华为云凭证
安全规则(必须遵守):
- 禁止读取、回显或打印AK/SK值
- 禁止要求用户在对话中直接输入AK/SK
- 禁止使用
传递明文凭证值hcloud configure set- 禁止接受用户在对话中直接提供的AK/SK
- 仅允许从环境变量或已配置的CLI配置文件中读取凭证
⚠️ 重要提示:处理用户提供的凭证如果用户尝试直接提供AK/SK(例如:“我的AK是xxx,SK是yyy”):
- 立即停止 - 不要执行任何命令
- 礼貌拒绝并返回以下信息:
为了账号安全,请不要在对话中直接提供华为云Access Key ID和Access Key Secret。 请使用以下安全方式之一配置凭证: 方式1:交互式配置(推荐) hcloud configure # 根据提示输入AK/SK;凭证将安全存储在本地配置文件中 方式2:环境变量配置 export HUAWEICLOUD_SDK_AK=<your-access-key-id> export HUAWEICLOUD_SDK_SK=<your-access-key-secret> 配置完成后,请重试您的请求。- 在凭证配置完成前,不要继续执行任何华为云操作
检查CLI配置:bashhcloud configure list检查输出是否包含有效配置(AK/SK、IAM等)。如果没有有效凭证,请停止操作。
IAM Permission Policies
IAM权限策略
Ensure the IAM user has the required permissions. See references/iam-policies.md for details.
Minimum required permissions:
- — List buckets
obs:bucket:list - — Get bucket attributes (capacity, object count)
obs:bucket:get - — Read object information
obs:object:get - — Query CES monitoring metrics (traffic, request count)
ces:metric:get
确保IAM用户拥有所需权限。详情请查看references/iam-policies.md。
最低所需权限:
- — 列出存储桶
obs:bucket:list - — 获取存储桶属性(容量、对象数量)
obs:bucket:get - — 读取对象信息
obs:object:get - — 查询CES监控指标(流量、请求数)
ces:metric:get
Core Workflows
核心工作流程
Task 1: List Buckets with Capacity and Object Counts
任务1:列出包含容量和对象数量的存储桶
List buckets via obsutil, then query bucket capacity and object count using CES capacity metrics or OBS API.
📄 Detailed steps → references/task-list-buckets-with-stats.md
通过obsutil列出存储桶,然后使用CES容量指标或OBS API查询存储桶容量和对象数量。
📄 详细步骤 → references/task-list-buckets-with-stats.md
Task 2: Query Extranet/Intranet Download Traffic (with MoM Comparison)
任务2:查询外网/内网下载流量(含月环比对比)
Query download traffic (extranet + intranet) via CES ShowMetricData, with month-over-month comparison.
📄 Detailed steps → references/task-query-traffic.md
通过CES ShowMetricData查询下载流量(外网+内网),并进行月环比对比。
📄 详细步骤 → references/task-query-traffic.md
Task 3: Query Total Requests (with MoM Comparison)
任务3:查询总请求数(含月环比对比)
Query total requests (sum of GET/PUT/POST/DELETE/HEAD) via CES ShowMetricData, with month-over-month comparison.
📄 Detailed steps → references/task-query-requests.md
通过CES ShowMetricData查询总请求数(GET/PUT/POST/DELETE/HEAD请求之和),并进行月环比对比。
📄 详细步骤 → references/task-query-requests.md
Core Commands
核心命令
| Command | Description |
|---|---|
| List all buckets (obsutil mode); filter by region via |
| Query CES metric data |
| Get bucket capacity & object count (may not be supported; fallback: |
| Traffic statistics with MoM |
| Request statistics with MoM |
⚠️ CESdoes not supportShowMetricData; appending it causes errors.--User-Agent
Common CES metrics:
Metric --metric_name--filterBucket capacity capacity_totalaverageExtranet download traffic download_traffic_extranetsumIntranet download traffic download_traffic_intranetsumGET / PUT / POST / DELETE / HEAD requests /get_request_count/put_request_count/post_request_count/delete_request_counthead_request_countsum
| 命令 | 描述 |
|---|---|
| 列出所有存储桶(obsutil模式);可通过 |
| 查询CES指标数据 |
| 获取存储桶容量和对象数量(可能不支持;备选方案: |
| 流量统计(含月环比) |
| 请求统计(含月环比) |
⚠️ CES不支持ShowMetricData;添加该参数会导致错误。--User-Agent
常见CES指标:
指标 --metric_name--filter存储桶容量 capacity_totalaverage外网下载流量 download_traffic_extranetsum内网下载流量 download_traffic_intranetsumGET / PUT / POST / DELETE / HEAD请求数 /get_request_count/put_request_count/post_request_count/delete_request_counthead_request_countsum
Parameter Confirmation
参数确认
Before executing any task, the following parameters must be confirmed with the user. Guessing is prohibited.
|| Parameter | Required/Optional | Description | Default ||
|| ----------- | ------------------ | ------------- | --------- ||
|| | Required | Huawei Cloud region (e.g., , ); must be explicitly provided by the user | - ||
|| Bucket name | Required | OBS bucket name; dimension format: | - ||
|| Time range | Required | Must precisely match user's wording: "this month" ≠ "last 30 days" (see table below) | - ||
|| obsutil credentials | Required | Check via before any OBS operation | - ||
|| | Optional | Traffic direction: / / | ||
|| | Optional | Also query 4xx/5xx error request counts | ||
--regioncn-south-1cn-north-4--dim.0=bucket_name,<BucketName>hcloud obs ls -limit=1--directiondownloaduploadbothdownload--include-errorsfalseTime range disambiguation:
User's wording Time range "this month" 1st of current month 00:00:00 ~ now "last 30 days" / "past month" now - 30 days ~ now "last month" 1st of last month 00:00:00 ~ last day of last month 23:59:59 Specific date range User-specified start and end times
在执行任何任务前,必须与用户确认以下参数。禁止猜测。
|| 参数 | 必填/可选 | 描述 | 默认值 ||
|| ----------- | ------------------ | ------------- | --------- ||
|| | 必填 | 华为云区域(例如:、);必须由用户明确提供 | - ||
|| 存储桶名称 | 必填 | OBS存储桶名称;维度格式: | - ||
|| 时间范围 | 必填 | 必须与用户表述完全匹配:“本月”≠“过去30天”(见下表) | - ||
|| obsutil凭证 | 必填 | 在执行任何OBS操作前,通过检查 | - ||
|| | 可选 | 流量方向: / / | ||
|| | 可选 | 同时查询4xx/5xx错误请求数 | ||
--regioncn-south-1cn-north-4--dim.0=bucket_name,<BucketName>hcloud obs ls -limit=1--directiondownloaduploadbothdownload--include-errorsfalse时间范围说明:
用户表述 时间范围 “本月” 当前月1日00:00:00 ~ 当前时间 “过去30天” / “近一个月” 当前时间-30天 ~ 当前时间 “上月” 上月1日00:00:00 ~ 上月最后一天23:59:59 特定日期范围 用户指定的开始和结束时间
Script Tools
脚本工具
This skill provides the following Python scripts that encapsulate best practices for traffic and request statistics:
本技能提供以下Python脚本,封装了流量和请求统计的最佳实践:
obs_traffic_stats.py — Download/Upload Traffic Statistics
obs_traffic_stats.py — 下载/上传流量统计
bash
undefinedbash
undefinedLast 30 days download traffic
过去30天下载流量
python3 scripts/obs_traffic_stats.py --region cn-south-1 --bucket obs-60030508 --period last_30d
python3 scripts/obs_traffic_stats.py --region cn-south-1 --bucket obs-60030508 --period last_30d
This month download + upload traffic
本月下载+上传流量
python3 scripts/obs_traffic_stats.py --region cn-south-1 --bucket obs-60030508 --period this_month --direction both
python3 scripts/obs_traffic_stats.py --region cn-south-1 --bucket obs-60030508 --period this_month --direction both
Custom date range
自定义日期范围
python3 scripts/obs_traffic_stats.py --region cn-south-1 --bucket obs-60030508 --from 2026-04-20 --to 2026-05-20
undefinedpython3 scripts/obs_traffic_stats.py --region cn-south-1 --bucket obs-60030508 --from 2026-04-20 --to 2026-05-20
undefinedobs_request_stats.py — Total Request Statistics
obs_request_stats.py — 总请求数统计
bash
undefinedbash
undefinedLast 30 days request count
过去30天请求数
python3 scripts/obs_request_stats.py --region cn-south-1 --bucket obs-60030508 --period last_30d
python3 scripts/obs_request_stats.py --region cn-south-1 --bucket obs-60030508 --period last_30d
This month request count (with 4xx/5xx error stats)
本月请求数(含4xx/5xx错误统计)
python3 scripts/obs_request_stats.py --region cn-south-1 --bucket obs-60030508 --period this_month --include-errors
python3 scripts/obs_request_stats.py --region cn-south-1 --bucket obs-60030508 --period this_month --include-errors
Custom date range
自定义日期范围
python3 scripts/obs_request_stats.py --region cn-south-1 --bucket obs-60030508 --from 2026-04-20 --to 2026-05-20
The scripts incorporate key lessons learned: traffic vs. bandwidth metrics, hcloud dimension parameter format, precise time range matching, OBS lacking a single request_count metric, etc.
---python3 scripts/obs_request_stats.py --region cn-south-1 --bucket obs-60030508 --from 2026-04-20 --to 2026-05-20
这些脚本整合了关键经验:流量与带宽指标的区别、hcloud维度参数格式、精确时间范围匹配、OBS缺少单一request_count指标等。
---Verification Method
验证方法
See references/verification-method.md for details.
Quick validation:
bash
undefined详情请查看references/verification-method.md。
快速验证:
bash
undefinedCheck OBS bucket list (using obsutil)
检查OBS存储桶列表(使用obsutil)
hcloud obs ls -limit=1
hcloud obs ls -limit=1
Check obsutil configuration
检查obsutil配置
obsutil ls -limit=1
obsutil ls -limit=1
Validate traffic stats script
验证流量统计脚本
python3 scripts/obs_traffic_stats.py --region cn-south-1 --bucket <BucketName> --period last_30d
python3 scripts/obs_traffic_stats.py --region cn-south-1 --bucket <BucketName> --period last_30d
Validate request stats script
验证请求统计脚本
python3 scripts/obs_request_stats.py --region cn-south-1 --bucket <BucketName> --period last_30d
---python3 scripts/obs_request_stats.py --region cn-south-1 --bucket <BucketName> --period last_30d
---References
参考文档
| Document | Description |
|---|---|
| task-list-buckets-with-stats.md | Task 1: List buckets with capacity and object counts |
| task-query-traffic.md | Task 2: Query download traffic with MoM |
| task-query-requests.md | Task 3: Query total requests with MoM |
| related-apis.md | API and CLI command details |
| iam-policies.md | IAM permission policies |
| obs-metrics.md | OBS CES monitoring metrics reference |
| verification-method.md | Verification steps |
| acceptance-criteria.md | Correct/error pattern comparison |
| cli-installation-guide.md | CLI installation guide |
| troubleshooting.md | Troubleshooting and practical experience |
| obs_traffic_stats.py | Traffic statistics script |
| obs_request_stats.py | Request statistics script |
| 文档 | 描述 |
|---|---|
| task-list-buckets-with-stats.md | 任务1:列出包含容量和对象数量的存储桶 |
| task-query-traffic.md | 任务2:查询下载流量并进行月环比对比 |
| task-query-requests.md | 任务3:查询总请求数并进行月环比对比 |
| related-apis.md | API和CLI命令详情 |
| iam-policies.md | IAM权限策略 |
| obs-metrics.md | OBS CES监控指标参考 |
| verification-method.md | 验证步骤 |
| acceptance-criteria.md | 正确/错误模式对比 |
| cli-installation-guide.md | CLI安装指南 |
| troubleshooting.md | 问题排查与实践经验 |
| obs_traffic_stats.py | 流量统计脚本 |
| obs_request_stats.py | 请求统计脚本 |