huawei-cloud-obs-stats

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Huawei 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 OperationAPI/CommandReason
❌ Delete bucket
DeleteBucket
/
obsutil rm -bucket
Irreversible; destroys the entire bucket and all objects
❌ Delete object
DeleteObject
/
obsutil rm
Irreversible; deleted objects cannot be recovered (unless versioning is enabled)
❌ Batch delete objects
DeleteObjects
/
obsutil rm -r
Irreversible; batch deletion has a wide impact
❌ Empty bucket
obsutil rm -bucket -r
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/命令原因
❌ 删除存储桶
DeleteBucket
/
obsutil rm -bucket
操作不可逆;会销毁整个存储桶及所有对象
❌ 删除对象
DeleteObject
/
obsutil rm
操作不可逆;删除的对象无法恢复(除非开启版本控制)
❌ 批量删除对象
DeleteObjects
/
obsutil rm -r
操作不可逆;批量删除影响范围广
❌ 清空存储桶
obsutil rm -bucket -r
操作不可逆;会移除存储桶内所有对象
若用户请求删除操作,必须拒绝并告知: "根据安全约束,本技能不允许执行删除操作(删除存储桶/对象/批量删除/清空存储桶)。请手动使用华为云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 Run
hcloud version
to verify version >= 3.2.0. If not installed or version is too low, see references/cli-installation-guide.md for installation guide.
bash
hcloud version
Prerequisite 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. Run
obsutil version
to verify version >= 5.5.0. If not installed, see references/cli-installation-guide.md for installation guide.
bash
obsutil version
Prerequisite check: obsutil credential configuration required
The 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:
bash
hcloud obs ls -limit=1
If the response is
Please set ak, sk and endpoint in the configuration file!
or
InvalidAccessKeyId
, obsutil credentials are not configured.
Resolution: 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 requirements
hcloud (KooCLI) all parameters must use the
--param=value
format
(connected with equals sign); space-separated format is not supported.
✅ Correct:
hcloud OBS ListBuckets --region=cn-south-1
❌ Incorrect:
hcloud OBS ListBuckets --region cn-south-1
[Conditional] CLI User-Agent
hcloud
OBS module commands may include a User-Agent header, but the CES module does not support this parameter:
  • ✅ OBS module:
    hcloud obs ls
  • ❌ CES module:
    hcloud CES ShowMetricData
    does not support
    --User-Agent
    ; appending it causes "Invalid parameter: User-Agent"

前置检查:需要Huawei Cloud CLI(hcloud / KooCLI)>= 3.2.0 运行
hcloud version
验证版本是否 >= 3.2.0。若未安装或版本过低,请查看references/cli-installation-guide.md获取安装指南。
bash
hcloud version
前置检查:需要obsutil >= 5.5.0(用于OBS存储桶列表查询) hcloud的OBS模块底层依赖obsutil工具。存储桶列表查询需要obsutil CLI工具。 运行
obsutil version
验证版本是否 >= 5.5.0。若未安装,请查看references/cli-installation-guide.md获取安装指南。
bash
obsutil version
前置检查:需要配置obsutil凭证
hcloud的OBS模块底层依赖obsutil,而obsutil需要单独配置AK/SK和Endpoint。 在执行OBS操作前,必须检查obsutil凭证是否已配置
bash
hcloud obs ls -limit=1
若返回结果为
Please set ak, sk and endpoint in the configuration file!
InvalidAccessKeyId
,则表示obsutil凭证未配置。
解决方法:提供以下示例命令,让用户在终端中进行配置(请勿要求用户在对话中直接提供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
hcloud
的OBS模块命令可能包含User-Agent请求头,但CES模块不支持该参数
  • ✅ OBS模块:
    hcloud obs ls
  • ❌ CES模块:
    hcloud CES ShowMetricData
    不支持
    --User-Agent
    ;添加该参数会导致“Invalid parameter: 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
    hcloud configure set
    to pass plaintext credential values
  • 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 credentials
If a user attempts to provide AK/SK directly (e.g., "my AK is xxx, SK is yyy"):
  1. Stop immediately - Do not execute any commands
  2. 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.
  3. Do not continue executing any Huawei Cloud operations until credentials are configured
Check CLI configuration:
bash
   hcloud configure list
Check 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”):
  1. 立即停止 - 不要执行任何命令
  2. 礼貌拒绝并返回以下信息:
    为了账号安全,请不要在对话中直接提供华为云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>
    
    配置完成后,请重试您的请求。
  3. 在凭证配置完成前,不要继续执行任何华为云操作
检查CLI配置:
bash
   hcloud 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:
  • obs:bucket:list
    — List buckets
  • obs:bucket:get
    — Get bucket attributes (capacity, object count)
  • obs:object:get
    — Read object information
  • ces:metric:get
    — Query CES monitoring metrics (traffic, request count)

确保IAM用户拥有所需权限。详情请查看references/iam-policies.md
最低所需权限:
  • obs:bucket:list
    — 列出存储桶
  • obs:bucket:get
    — 获取存储桶属性(容量、对象数量)
  • obs:object:get
    — 读取对象信息
  • ces:metric:get
    — 查询CES监控指标(流量、请求数)

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

核心命令

CommandDescription
hcloud obs ls
List all buckets (obsutil mode); filter by region via
grep
hcloud CES ShowMetricData --region=<R> --namespace=SYS.OBS --metric_name=<M> --dim.0=bucket_name,<B> --period=86400 --filter=<F> --from=<ms> --to=<ms>
Query CES metric data
hcloud OBS GetBucketStorageInfo --region=<R> --bucket=<B>
Get bucket capacity & object count (may not be supported; fallback:
obsutil ls obs://<B> -limit=0 -s
)
python3 scripts/obs_traffic_stats.py --region <R> --bucket <B> (--period <P> | --from <D> --to <D>) [--direction download|upload|both]
Traffic statistics with MoM
python3 scripts/obs_request_stats.py --region <R> --bucket <B> (--period <P> | --from <D> --to <D>) [--include-errors]
Request statistics with MoM
⚠️ CES
ShowMetricData
does not support
--User-Agent
; appending it causes errors.
Common CES metrics:
Metric
--metric_name
--filter
Bucket capacity
capacity_total
average
Extranet download traffic
download_traffic_extranet
sum
Intranet download traffic
download_traffic_intranet
sum
GET / PUT / POST / DELETE / HEAD requests
get_request_count
/
put_request_count
/
post_request_count
/
delete_request_count
/
head_request_count
sum

命令描述
hcloud obs ls
列出所有存储桶(obsutil模式);可通过
grep
按区域过滤
hcloud CES ShowMetricData --region=<R> --namespace=SYS.OBS --metric_name=<M> --dim.0=bucket_name,<B> --period=86400 --filter=<F> --from=<ms> --to=<ms>
查询CES指标数据
hcloud OBS GetBucketStorageInfo --region=<R> --bucket=<B>
获取存储桶容量和对象数量(可能不支持;备选方案:
obsutil ls obs://<B> -limit=0 -s
python3 scripts/obs_traffic_stats.py --region <R> --bucket <B> (--period <P> | --from <D> --to <D>) [--direction download|upload|both]
流量统计(含月环比)
python3 scripts/obs_request_stats.py --region <R> --bucket <B> (--period <P> | --from <D> --to <D>) [--include-errors]
请求统计(含月环比)
⚠️ CES
ShowMetricData
不支持
--User-Agent
;添加该参数会导致错误。
常见CES指标:
指标
--metric_name
--filter
存储桶容量
capacity_total
average
外网下载流量
download_traffic_extranet
sum
内网下载流量
download_traffic_intranet
sum
GET / PUT / POST / DELETE / HEAD请求数
get_request_count
/
put_request_count
/
post_request_count
/
delete_request_count
/
head_request_count
sum

Parameter Confirmation

参数确认

Before executing any task, the following parameters must be confirmed with the user. Guessing is prohibited.
|| Parameter | Required/Optional | Description | Default || || ----------- | ------------------ | ------------- | --------- || ||
--region
| Required | Huawei Cloud region (e.g.,
cn-south-1
,
cn-north-4
); must be explicitly provided by the user | - || || Bucket name | Required | OBS bucket name; dimension format:
--dim.0=bucket_name,<BucketName>
| - || || Time range | Required | Must precisely match user's wording: "this month" ≠ "last 30 days" (see table below) | - || || obsutil credentials | Required | Check via
hcloud obs ls -limit=1
before any OBS operation | - || ||
--direction
| Optional | Traffic direction:
download
/
upload
/
both
|
download
|| ||
--include-errors
| Optional | Also query 4xx/5xx error request counts |
false
||
Time range disambiguation:
User's wordingTime 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 rangeUser-specified start and end times

在执行任何任务前,必须与用户确认以下参数。禁止猜测。
|| 参数 | 必填/可选 | 描述 | 默认值 || || ----------- | ------------------ | ------------- | --------- || ||
--region
| 必填 | 华为云区域(例如:
cn-south-1
cn-north-4
);必须由用户明确提供 | - || || 存储桶名称 | 必填 | OBS存储桶名称;维度格式:
--dim.0=bucket_name,<BucketName>
| - || || 时间范围 | 必填 | 必须与用户表述完全匹配:“本月”≠“过去30天”(见下表) | - || || obsutil凭证 | 必填 | 在执行任何OBS操作前,通过
hcloud obs ls -limit=1
检查 | - || ||
--direction
| 可选 | 流量方向:
download
/
upload
/
both
|
download
|| ||
--include-errors
| 可选 | 同时查询4xx/5xx错误请求数 |
false
||
时间范围说明:
用户表述时间范围
“本月”当前月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
undefined
bash
undefined

Last 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
undefined
python3 scripts/obs_traffic_stats.py --region cn-south-1 --bucket obs-60030508 --from 2026-04-20 --to 2026-05-20
undefined

obs_request_stats.py — Total Request Statistics

obs_request_stats.py — 总请求数统计

bash
undefined
bash
undefined

Last 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
undefined

Check 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

参考文档

DocumentDescription
task-list-buckets-with-stats.mdTask 1: List buckets with capacity and object counts
task-query-traffic.mdTask 2: Query download traffic with MoM
task-query-requests.mdTask 3: Query total requests with MoM
related-apis.mdAPI and CLI command details
iam-policies.mdIAM permission policies
obs-metrics.mdOBS CES monitoring metrics reference
verification-method.mdVerification steps
acceptance-criteria.mdCorrect/error pattern comparison
cli-installation-guide.mdCLI installation guide
troubleshooting.mdTroubleshooting and practical experience
obs_traffic_stats.pyTraffic statistics script
obs_request_stats.pyRequest statistics script
文档描述
task-list-buckets-with-stats.md任务1:列出包含容量和对象数量的存储桶
task-query-traffic.md任务2:查询下载流量并进行月环比对比
task-query-requests.md任务3:查询总请求数并进行月环比对比
related-apis.mdAPI和CLI命令详情
iam-policies.mdIAM权限策略
obs-metrics.mdOBS CES监控指标参考
verification-method.md验证步骤
acceptance-criteria.md正确/错误模式对比
cli-installation-guide.mdCLI安装指南
troubleshooting.md问题排查与实践经验
obs_traffic_stats.py流量统计脚本
obs_request_stats.py请求统计脚本