Install
openclaw skills install @sdk-team/alibabacloud-waf-billing-backupQuery and back up Alibaba Cloud WAF 3.0 billing data. Use this Skill when a user asks to check WAF bills, export WAF cost details, back up WAF billing data locally, or analyze daily/hourly SeCU and Credit usage. The Skill retrieves instance information, daily bill summaries, and hourly cost breakdowns (function fees, traffic processing fees, Credit usage) via aliyun-cli, then exports the results as JSON and CSV files to the local workspace.
openclaw skills install @sdk-team/alibabacloud-waf-billing-backupRead-only Skill: This Skill only invokes Describe/List read-only APIs. Any Create/Modify/Delete/Release operation is strictly prohibited.
Query Alibaba Cloud WAF 3.0 billing data via OpenAPI. This Skill supports:
Verify the aliyun-cli version:
aliyun version
Version >= 3.3.3 is required. If it is not installed or the version is too low, refer to references/cli-installation-guide.md.
Security rules:
~/.aliyun/config.json)aliyun configure set with plaintext credential valuesaliyun configure list is allowed to check credential statusaliyun configure list
If no valid configuration exists, prompt the user to configure credentials before retrying. Reference: https://help.aliyun.com/zh/cli/configure-credentials
This Skill requires read-only WAF permissions. See references/ram-policies.md for the full minimum RAM policy.
All aliyun commands must include:
--version 2021-10-01 --force --read-timeout 30 --connect-timeout 10 --user-agent AlibabaCloud-Agent-Skills
aliyun waf-openapi describe-instance \
--version 2021-10-01 --force \
--region cn-hangzhou \
--read-timeout 30 --connect-timeout 10 \
--user-agent AlibabaCloud-Agent-Skills
Extract from the returned JSON:
InstanceId: WAF instance IDRegionId: instance region (cn-hangzhou for Mainland China, ap-southeast-1 for outside Mainland China)Region selection rules:
--region cn-hangzhou.cn-hangzhou returns an empty instance, retry with --region ap-southeast-1.Always record the final RegionId actually used for subsequent bill queries.
Determine the instance type from the PayType field returned by describe-instance:
POSTPAY: pay-as-you-go instance; use describe-postpay-bills / describe-elastic-billsPREPAY: subscription instance; for elastic postpaid bills use describe-prepay-daily-billsDefault time-range rules:
Important reminder: WAF 3.0 pay-as-you-go bills are settled on a T+1 basis. If the query range includes today, only the estimated bill up to the last complete hour can be retrieved. The final bill for today will be generated on the next day. Before execution, inform the user: "Data for today is an estimated bill; the final bill is subject to T+1 actual settlement."
T+1 auto-adjustment rule: If the user's request is about "today" or the natural query range ends on today, you must adjust the bill query to yesterday (00:00:00 yesterday to 23:59:59 yesterday) and clearly state: "Because WAF 3.0 pay-as-you-go bills are settled on a T+1 basis, today's final bill is not yet available. I have adjusted the query to yesterday's final bill." Do not query today's data as the final answer unless the user explicitly asks for an estimated bill.
Calculate Unix timestamps (seconds, UTC):
# Last 7 days
START_TS=$(date -u -v-7d +%s)
END_TS=$(date -u +%s)
# Specific date (macOS)
START_TS=$(date -u -j -f '%Y-%m-%d %H:%M:%S' '2026-08-23 00:00:00' +%s)
END_TS=$(date -u -j -f '%Y-%m-%d %H:%M:%S' '2026-08-23 23:59:59' +%s)
# Linux alternative
# START_TS=$(date -u -d '2026-08-23 00:00:00' +%s)
# END_TS=$(date -u -d '2026-08-23 23:59:59' +%s)
Suitable for the "bill list" view. For daily granularity, do not pass PeriodType; the API defaults to daily aggregation:
aliyun waf-openapi describe-postpay-bills \
--version 2021-10-01 --force \
--region <RegionId> \
--InstanceId <InstanceId> \
--StartTime <START_TS> \
--EndTime <END_TS> \
--MaxResults 100 \
--read-timeout 30 --connect-timeout 10 \
--user-agent AlibabaCloud-Agent-Skills
The returned BillDetail array contains daily Cu, TrafficCu, FunctionCu, Credit, ChargeData, etc.
Corresponds to the console "View Details → Hourly Cost Details". You must explicitly pass --PeriodType hour to retrieve hourly breakdowns. Omitting this parameter may return daily data instead of hourly data:
aliyun waf-openapi describe-postpay-bills \
--version 2021-10-01 --force \
--region <RegionId> \
--InstanceId <InstanceId> \
--StartTime <START_TS> \
--EndTime <END_TS> \
--PeriodType hour \
--MaxResults 24 \
--read-timeout 30 --connect-timeout 10 \
--user-agent AlibabaCloud-Agent-Skills
Important: Always invoke this as a separate call from the daily summary query. The daily summary (Step 3) and the hourly details (Step 4) must be two distinct
aliyuncommands. The only difference from Step 3 is the addition of--PeriodType hour. Do not rely on the API default granularity for hourly details; explicitly pass--PeriodType hourevery time hourly breakdown is required.
For each returned record:
ChargeData (JSON string) to obtain SeCU function/traffic usage detailsCreditChargeData (JSON string) to obtain Credit usage details| Metering Unit | Unit Price |
|---|---|
| SeCU | 0.05 CNY / SeCU |
| Credit | 100 Credit = 1 CNY |
Cost for a single record:
Cost(CNY) = Cu * 0.05 + Credit * 0.01
Except for the WAF instance fee, SeCU is counted per full hour and rounded up. The WAF instance fee is billed at the actual rate of 0.5 SeCU/hour.
Backup directories are organized in a year/month/day hierarchy for long-term archiving:
waf-billing-backups/
├── 2026/
│ ├── 08/
│ │ ├── 23/
│ │ │ ├── waf-billing-raw-20260823-2047.json
│ │ │ ├── waf-billing-daily-20260823-2047.csv
│ │ │ ├── waf-billing-hourly-20260823-2047.csv
│ │ │ └── waf-billing-chargedata-20260823-2047.csv
│ │ └── 24/
│ │ └── ...
Example of generating directories and saving files (macOS/Linux):
# Directory hierarchy based on the query end date
BACKUP_YEAR=$(date -u -r <END_TS> +%Y)
BACKUP_MONTH=$(date -u -r <END_TS> +%m)
BACKUP_DAY=$(date -u -r <END_TS> +%d)
BACKUP_DIR="./waf-billing-backups/${BACKUP_YEAR}/${BACKUP_MONTH}/${BACKUP_DAY}"
mkdir -p "$BACKUP_DIR"
# File name timestamp
TIMESTAMP=$(date -u +%Y%m%d-%H%M)
# Save raw API response
aliyun ... > "${BACKUP_DIR}/waf-billing-raw-${TIMESTAMP}.json"
# Summary CSV example columns
# date,hour,cu,traffic_cu,function_cu,credit,traffic_credit,function_credit,cost_rmb
Linux alternative:
date -u -d @<END_TS> +%Y/%m/%d
Backup file naming convention:
waf-billing-raw-{YYYYMMDD-HHMM}.jsonwaf-billing-daily-{YYYYMMDD-HHMM}.csvwaf-billing-hourly-{YYYYMMDD-HHMM}.csvwaf-billing-chargedata-{YYYYMMDD-HHMM}.csvOutput a Markdown summary to the user:
## WAF 3.0 Billing Summary
- **Instance ID**: {InstanceId}
- **Query Range**: {START} ~ {END}
- **Total SeCU**: {total_cu}
- **Total Credit**: {total_credit}
- **Estimated Total Cost**: {total_cost} CNY
### Daily Summary
| Date | SeCU | Credit | Cost(CNY) |
| --- | --- | --- | --- |
| 2026-08-23 | 1184 | 0 | 59.20 |
| ... | ... | ... | ... |
### Local Backup Files
- `waf-billing-raw-20260824-2047.json`
- `waf-billing-daily-20260824-2047.csv`
- `waf-billing-hourly-20260824-2047.csv`
| Scenario | Detection | Handling |
|---|---|---|
| Missing/invalid credentials | InvalidAccessKeyId.NotFound, SignatureDoesNotMatch | Prompt user to check aliyun configure list |
| Insufficient RAM permissions | Forbidden.RAM, NoPermission | Prompt user to add permissions from references/ram-policies.md |
| Instance does not exist | Empty InstanceId returned | Retry with another --region or confirm the instance is activated |
| Invalid time range | InvalidParameter | Check StartTime / EndTime are Unix timestamps in seconds |
| Query range includes today | EndTime >= 00:00:00 today | Inform user: "Today is an estimated bill; the final bill is subject to T+1 settlement" |
| Throttling | Throttling | Wait 2 seconds and retry, up to 3 times |
All aliyun CLI commands invoked by this Skill must include the following User-Agent header template:
--user-agent AlibabaCloud-Agent-Skills/{SKILL_NAME}/{session-id}
At runtime, replace the placeholders:
{SKILL_NAME} → alibabacloud-waf-billing-backup{session-id} → a unique 32-character hexadecimal identifier for the current Skill execution sessiona1b2c3d4e5f678901234567890123456).session-id must be reused across all API calls within a single Skill execution.| Reference | Description |
|---|---|
references/cli-installation-guide.md | aliyun-cli installation and configuration guide |
references/ram-policies.md | Minimum RAM permissions required |
references/billing-fields-reference.md | Billing field and cost item mapping |
related_apis.yaml | OpenAPI list invoked by this Skill |