alibabacloud-odps-cost-analysis

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

MaxCompute Cost Analysis

MaxCompute成本分析

Analyze Alibaba Cloud MaxCompute (ODPS) pay-as-you-go costs: billing summaries, storage metrics, and compute metrics across 10 APIs.
⚠️ MANDATORY PRODUCT CONSTRAINT: This skill uses ONLY the 10
aliyun maxcompute
CLI commands listed in API Overview below (plugin mode, version 2022-01-04). NEVER use
aliyun bssopenapi
or any of its actions (billing queries, instance bills, etc.). NEVER use other MaxCompute APIs not in the 10-API list (e.g.,
list-job-infos
,
get-running-jobs
,
list-projects
,
list-tables
,
get-storage-amount-summary
). NEVER use any other product CLI (
aliyun odps
,
aliyun dataworks
,
aliyun compute-nest
,
aliyun cms
,
aliyun actiontrail
, etc.). If
aliyun maxcompute
commands fail, fix the plugin — do NOT fall back to other APIs or products.
Intent → API Mapping (use ONLY these):
  • Billing/费用 →
    sum-bills
    ,
    sum-bills-by-date
    ,
    sum-daily-bills-by-item
  • Daily cost spike/费用突增/每日趋势
    sum-bills-by-date
    (MANDATORY for locating spike dates — NOT
    sum-daily-bills-by-item
    )
  • Paginated daily billing details/每日账单明细/按计费项的每日账单
    sum-daily-bills-by-item
    (MANDATORY — NOT any
    bssopenapi
    command)
  • Storage/存储 →
    sum-storage-metrics-by-type
    AND
    sum-storage-metrics-by-date
    (BOTH MANDATORY —
    sum-storage-metrics-by-type
    alone is NOT sufficient)
  • Compute jobs/计算作业/expensive jobs/贵的作业 →
    list-compute-metrics-by-instance
    (MANDATORY — NEVER use
    list-job-infos
    ,
    get-running-jobs
    ,
    get-job-resource-usage
    )
  • SQL signatures/SQL签名/重复SQL/扫描量
    list-compute-metrics-by-signature
    (MANDATORY for any SQL pattern analysis)
  • SCAN usage trends/扫描量趋势/CU usage
    sum-compute-metrics-by-usage
    (MANDATORY — usageType=SCAN or CU; NEVER use CloudMonitor or ActionTrail)
  • Compute record counts →
    sum-compute-metrics-by-record
分析阿里云MaxCompute(ODPS)按需付费成本:涵盖10个API的账单汇总、存储指标和计算指标。
⚠️ 强制产品约束: 本Skill仅使用下方API概览中列出的10个
aliyun maxcompute
CLI命令(插件模式,版本2022-01-04)。 禁止使用
aliyun bssopenapi
或其任何操作(账单查询、实例账单等)。 禁止使用10个API列表之外的其他MaxCompute API(例如
list-job-infos
get-running-jobs
list-projects
list-tables
get-storage-amount-summary
)。 禁止使用其他产品的CLI(
aliyun odps
aliyun dataworks
aliyun compute-nest
aliyun cms
aliyun actiontrail
等)。 如果
aliyun maxcompute
命令执行失败,修复插件——不要切换到其他API或产品。
意图→API映射(仅使用以下API):
  • 账单/费用 →
    sum-bills
    sum-bills-by-date
    sum-daily-bills-by-item
  • 每日费用突增/费用突增/每日趋势
    sum-bills-by-date
    (定位突增日期的强制API——禁止使用
    sum-daily-bills-by-item
  • 分页每日账单明细/每日账单明细/按计费项的每日账单
    sum-daily-bills-by-item
    (强制API——禁止使用任何
    bssopenapi
    命令)
  • 存储/存储 →
    sum-storage-metrics-by-type
    sum-storage-metrics-by-date
    (两个都必须使用——仅使用
    sum-storage-metrics-by-type
    不满足要求)
  • 计算作业/计算作业/高成本作业/贵的作业 →
    list-compute-metrics-by-instance
    (强制API——禁止使用
    list-job-infos
    get-running-jobs
    get-job-resource-usage
  • SQL签名/SQL签名/重复SQL/扫描量
    list-compute-metrics-by-signature
    (任何SQL模式分析的强制API)
  • 扫描量趋势/扫描量趋势/CU使用量
    sum-compute-metrics-by-usage
    (强制API——usageType=SCAN或CU;禁止使用CloudMonitor或ActionTrail)
  • 计算记录数 →
    sum-compute-metrics-by-record

Prerequisites

前置条件

Pre-check: Aliyun CLI >= 3.3.3 required
Run
aliyun version
to verify >= 3.3.3. If not installed or version too low, run
curl -fsSL https://aliyuncli.alicdn.com/setup.sh | bash
to update, or see
references/cli-installation-guide.md
for installation instructions.
Then [MUST] run
aliyun plugin update
to ensure that any existing plugins on your local machine are always up-to-date.
[MUST] CLI User-Agent — Every
aliyun
CLI command invocation must include:
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
[MUST] AI-Mode Commands — When using aliyun CLI, declare AI-Mode lifecycle:
  1. Enable AI-Mode before commands:
    bash
    aliyun configure ai-mode enable
  2. Set User-Agent for AI-Mode:
    bash
    aliyun configure ai-mode set-user-agent --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis"
  3. Disable AI-Mode after workflow ends:
    bash
    aliyun configure ai-mode disable
预检查:需要Aliyun CLI >= 3.3.3
运行
aliyun version
验证版本是否>=3.3.3。如果未安装或版本过低, 运行
curl -fsSL https://aliyuncli.alicdn.com/setup.sh | bash
进行更新, 或查看
references/cli-installation-guide.md
获取安装说明。
然后[必须]运行
aliyun plugin update
确保本地所有现有插件始终保持最新。
[必须] CLI User-Agent — 每次调用
aliyun
CLI命令必须包含:
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
[必须] AI模式命令 — 使用aliyun CLI时,声明AI模式生命周期:
  1. 命令前启用AI模式:
    bash
    aliyun configure ai-mode enable
  2. 为AI模式设置User-Agent:
    bash
    aliyun configure ai-mode set-user-agent --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis"
  3. 工作流结束后禁用AI模式:
    bash
    aliyun configure ai-mode disable

Quick Start

快速开始

When user asks about MaxCompute cost analysis, follow these steps:
  1. Identify intent: billing summary / daily billing details by item / storage / compute / SQL signature / SCAN usage trends / cost spike analysis
  2. Get RegionId: Ask user which region (e.g., cn-hangzhou, cn-shanghai)
  3. Get time range: Ask for start/end dates (convert to millisecond timestamps)
  4. Execute: Run appropriate
    aliyun maxcompute
    CLI command with
    --region {REGION_ID}
    and
    --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    IMPORTANT: ALL commands MUST start with
    aliyun maxcompute
    . NEVER use
    aliyun bssopenapi
    or any other product.
  5. Verify: Confirm results and present to user
当用户询问MaxCompute成本分析相关问题时,按照以下步骤操作:
  1. 识别意图:账单汇总 / 按计费项的每日账单明细 / 存储 / 计算 / SQL签名 / 扫描量趋势 / 费用突增分析
  2. 获取RegionId:询问用户所属地域(例如cn-hangzhou、cn-shanghai)
  3. 获取时间范围:询问开始/结束日期(转换为毫秒级时间戳)
  4. 执行命令:运行相应的
    aliyun maxcompute
    CLI命令,添加
    --region {REGION_ID}
    --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    重要提示: 所有命令必须以
    aliyun maxcompute
    开头。禁止使用
    aliyun bssopenapi
    或其他任何产品的命令。
  5. 验证结果:确认结果并呈现给用户

Data Limitations

数据限制

  • Only pay-as-you-go billing is supported
  • Data available from 2023-05-07 onwards
  • Query up to last 12 months only
  • Single query range: max 31 days
  • Costs are estimated usage-based prices (may differ slightly from actual bills)
  • 仅支持按需付费账单
  • 数据从2023-05-07开始可用
  • 仅可查询最近12个月的数据
  • 单次查询范围:最多31天
  • 成本为基于使用量的估算价格(可能与实际账单略有差异)

Pre-flight Checklist (Execute BEFORE every command)

执行前检查清单(每次命令执行前完成)

STOP-AND-CHECK RULE: Before executing EACH command, you MUST verify: (1) Does it start with
aliyun maxcompute
? (2) Is the API name in the 10-API list? (3) Does it include
--user-agent
? If ANY answer is NO, do NOT execute — fix first.
  • My command includes
    --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  • My command starts with
    aliyun maxcompute
    (NOT
    aliyun bssopenapi
    , NOT any other product)
  • My command uses one of the 10 APIs listed in API Overview (NOT
    list-job-infos
    ,
    get-running-jobs
    ,
    list-projects
    ,
    list-tables
    , etc.)
  • I have verified the maxcompute plugin is installed (
    aliyun maxcompute --help
    succeeds)
  • I have asked the user for RegionId (not using default)
  • I have the actual RegionId value from user (not placeholder)
  • My command includes
    --region {ACTUAL_REGION_ID}
  • Time range does not exceed 31 days
  • Timestamps are in milliseconds
  • I am NOT reading or echoing any AK/SK values
  • I am NOT using
    aliyun bssopenapi
    or any of its actions
If ANY check fails, STOP and fix before proceeding.
停止检查规则: 执行每个命令前,必须验证:(1) 命令是否以
aliyun maxcompute
开头?(2) API名称是否在10个API列表中?(3) 是否包含
--user-agent
?如果任何一个答案为否,请勿执行——先修复问题。
  • 我的命令包含
    --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  • 我的命令以
    aliyun maxcompute
    开头
    (不是
    aliyun bssopenapi
    ,也不是其他任何产品的命令)
  • 我的命令使用API概览中列出的10个API之一(不是
    list-job-infos
    get-running-jobs
    list-projects
    list-tables
    等)
  • 我已验证maxcompute插件已安装(
    aliyun maxcompute --help
    执行成功)
  • 我已向用户询问RegionId(未使用默认值)
  • 我已从用户处获取实际的RegionId值(不是占位符)
  • 我的命令包含
    --region {ACTUAL_REGION_ID}
  • 时间范围不超过31天
  • 时间戳为毫秒级
  • 我未读取或回显任何AK/SK值
  • 我未使用
    aliyun bssopenapi
    或其任何操作
如果任何一项检查未通过,请停止操作并修复后再继续。

API Overview

API概览

APIDescriptionMethodCategory
list-instancesGet instance/project list (NOT compute metrics — see
list-compute-metrics-by-instance
for job-level data)
GETInstance
sum-billsSummarize bills by project or fee itemPOSTBilling
sum-bills-by-dateDaily bill trends (USE THIS for spike analysis)POSTBilling
sum-daily-bills-by-itemDaily bill details by item (paginated drill-down)POSTBilling
sum-storage-metrics-by-typeStorage grouped by TYPEPOSTStorage
sum-storage-metrics-by-dateStorage daily DATE trends (MUST call separately)POSTStorage
list-compute-metrics-by-instanceCompute JOB METRICS per instance (cost, duration, input size)POSTCompute
list-compute-metrics-by-signatureCompute by SQL signaturePOSTCompute
sum-compute-metrics-by-usageCompute usage trendsPOSTCompute
sum-compute-metrics-by-recordCompute record countsPOSTCompute
⚠️ API Disambiguation — Do NOT confuse these two billing APIs:
  • sum-bills-by-date
    = Daily cost TRENDS → Use this to locate spike dates (returns cost per day)
  • sum-daily-bills-by-item
    = Daily bill DETAILS by item → Use this for drill-down after finding spikes (paginated, returns per-item breakdown)
For cost spike investigation, you MUST call
sum-bills-by-date
first.
sum-daily-bills-by-item
is optional for drill-down only.
⚠️ API Disambiguation — Do NOT confuse these two "instance" APIs:
  • list-instances
    = Returns the PROJECT/INSTANCE LIST (for scoping which projects to analyze)
  • list-compute-metrics-by-instance
    = Returns COMPUTE JOB METRICS (cost, duration, input size per job)
These are COMPLETELY DIFFERENT APIs.
list-instances
does NOT return compute metrics. You MUST call BOTH.
⚠️ API Disambiguation — Do NOT confuse these two storage APIs:
  • sum-storage-metrics-by-type
    = Storage grouped by TYPE (may include
    dailyStorageMetrics
    in response, but this does NOT replace
    sum-storage-metrics-by-date
    )
  • sum-storage-metrics-by-date
    = Storage daily DATE trends (dedicated API for daily storage trends)
Even if
sum-storage-metrics-by-type
returns daily data in its response, you MUST still call
sum-storage-metrics-by-date
separately when daily trends are needed.
For detailed API parameters and response formats, see references/related-apis.md.
API描述方法分类
list-instances获取实例/项目列表(不包含计算指标——如需作业级数据请查看
list-compute-metrics-by-instance
GET实例
sum-bills按项目或计费项汇总账单POST账单
sum-bills-by-date每日账单趋势(用于突增分析)POST账单
sum-daily-bills-by-item按计费项拆分的每日账单明细(分页钻取)POST账单
sum-storage-metrics-by-type按类型分组的存储数据POST存储
sum-storage-metrics-by-date存储每日趋势(必须单独调用)POST存储
list-compute-metrics-by-instance每个实例的计算作业指标(成本、时长、输入大小)POST计算
list-compute-metrics-by-signature按SQL签名统计的计算数据POST计算
sum-compute-metrics-by-usage计算使用量趋势POST计算
sum-compute-metrics-by-record计算记录数统计POST计算
⚠️ API区分——不要混淆以下两个账单API:
  • sum-bills-by-date
    = 每日成本趋势 → 用于定位突增日期(返回每日成本)
  • sum-daily-bills-by-item
    = 按计费项拆分的每日账单明细 → 用于找到突增点后的钻取分析(分页,返回按项拆分的明细)
对于费用突增调查,必须先调用
sum-bills-by-date
sum-daily-bills-by-item
仅用于可选的钻取分析。
⚠️ API区分——不要混淆以下两个"instance"API:
  • list-instances
    = 返回项目/实例列表(用于确定要分析的项目范围)
  • list-compute-metrics-by-instance
    = 返回计算作业指标(每个作业的成本、时长、输入大小)
这是完全不同的API。
list-instances
不返回计算指标。必须同时调用两个API。
⚠️ API区分——不要混淆以下两个存储API:
  • sum-storage-metrics-by-type
    = 按类型分组的存储数据(响应中可能包含
    dailyStorageMetrics
    ,但不能替代
    sum-storage-metrics-by-date
  • sum-storage-metrics-by-date
    = 存储每日趋势(专门用于每日存储趋势的API)
即使
sum-storage-metrics-by-type
的响应中返回了每日数据,当需要每日趋势时,仍必须单独调用
sum-storage-metrics-by-date
有关详细的API参数和响应格式,请查看references/related-apis.md

Task Completion Checklist

任务完成检查清单

CRITICAL: You MUST complete ALL steps in order. Do NOT stop early.
关键提示:必须按顺序完成所有步骤。请勿提前停止。

For Cost Spike Investigation:

费用突增调查:

  1. Ask user: "Which region? (e.g., cn-hangzhou)"
  2. Ask user: "What time range to analyze? (max 31 days)"
  3. Convert dates to millisecond timestamps
  4. Execute list-instances to get available instances (this is the PROJECT LIST, NOT compute metrics):
    bash
    aliyun maxcompute list-instances --region {REGION_ID} --startDate {START_MS} --endDate {END_MS} --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    ⚠️
    list-instances
    only returns the project/instance list for scoping. It does NOT return compute job metrics. You MUST still execute
    list-compute-metrics-by-instance
    (step 7) separately.
  5. MANDATORY Execute sum-bills with
    statsType=FEE_ITEM
    to identify top cost drivers:
    bash
    aliyun maxcompute sum-bills --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"FEE_ITEM","topN":10}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    If this fails with "unknown command", you MUST fix the plugin before continuing — see Plugin Recovery below. NEVER skip this step or substitute with a non-billing API.
  6. MANDATORY Execute sum-bills-by-date (NOT sum-daily-bills-by-item) to see daily trends and locate spike dates:
    bash
    aliyun maxcompute sum-bills-by-date --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"FEE_ITEM","topN":8}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    ⚠️
    sum-bills-by-date
    sum-daily-bills-by-item
    . For locating spike dates, you MUST use
    sum-bills-by-date
    . Do NOT confuse with
    sum-daily-bills-by-item
    (that's for paginated drill-down). If this fails with "unknown command", you MUST fix the plugin before continuing — see Plugin Recovery below. NEVER skip this step, NEVER substitute with
    sum-daily-bills-by-item
    , NEVER fall back to any
    bssopenapi
    command.
    ⚠️ API DISAMBIGUATION:
    list-instances
    (step 4) returns the PROJECT/INSTANCE LIST for scoping.
    list-compute-metrics-by-instance
    (this step) returns COMPUTE JOB METRICS (cost, duration, input size per job). These are COMPLETELY DIFFERENT APIs. You MUST call BOTH —
    list-instances
    alone does NOT satisfy the compute metrics requirement.
  7. MANDATORY Execute list-compute-metrics-by-instance (NOT
    list-instances
    , NOT
    list-job-infos
    , NOT
    get-running-jobs
    , NOT
    get-job-resource-usage
    ) to find expensive compute jobs:
    bash
    aliyun maxcompute list-compute-metrics-by-instance --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"types":["ComputationSql"],"pageNumber":1,"pageSize":10}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  8. If storage costs are high: use sum-storage-metrics-by-type to analyze storage distribution:
    bash
    aliyun maxcompute sum-storage-metrics-by-type --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"STORAGE_TYPE"}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  9. MANDATORY Execute sum-daily-bills-by-item for paginated daily billing details:
    bash
    aliyun maxcompute sum-daily-bills-by-item --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"FEE_ITEM","pageNumber":1,"pageSize":10}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    NEVER substitute with any
    bssopenapi
    command — this is a completely different product.
  10. Present findings with cost breakdown to user
  11. Suggest optimization actions
Plugin Recovery (execute when
aliyun maxcompute sum-bills
or
sum-bills-by-date
returns "unknown command"):
bash
aliyun configure set --auto-plugin-install true
aliyun plugin install maxcompute
aliyun plugin update maxcompute
  1. 询问用户:"所属地域是?(例如cn-hangzhou)"
  2. 询问用户:"要分析的时间范围是?(最多31天)"
  3. 将日期转换为毫秒级时间戳
  4. 执行list-instances获取可用实例(这是项目列表,不是计算指标):
    bash
    aliyun maxcompute list-instances --region {REGION_ID} --startDate {START_MS} --endDate {END_MS} --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    ⚠️
    list-instances
    仅返回用于范围确定的项目/实例列表。它不返回计算作业指标。仍必须单独执行
    list-compute-metrics-by-instance
    (步骤7)。
  5. 强制执行sum-bills并设置
    statsType=FEE_ITEM
    以确定主要成本驱动因素:
    bash
    aliyun maxcompute sum-bills --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"FEE_ITEM","topN":10}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    如果执行失败并提示"unknown command",必须先修复插件再继续——请查看下方的插件恢复方法。请勿跳过此步骤或替换为非账单API。
  6. 强制执行sum-bills-by-date(不是sum-daily-bills-by-item)查看每日趋势并定位突增日期:
    bash
    aliyun maxcompute sum-bills-by-date --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"FEE_ITEM","topN":8}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    ⚠️
    sum-bills-by-date
    sum-daily-bills-by-item
    。定位突增日期必须使用
    sum-bills-by-date
    。请勿与
    sum-daily-bills-by-item
    混淆(后者用于分页钻取)。 如果执行失败并提示"unknown command",必须先修复插件再继续——请查看下方的插件恢复方法。请勿跳过此步骤,请勿替换为
    sum-daily-bills-by-item
    ,请勿切换到任何
    bssopenapi
    命令。
    ⚠️ API区分:
    list-instances
    (步骤4)返回用于范围确定的项目/实例列表。
    list-compute-metrics-by-instance
    (此步骤)返回计算作业指标(每个作业的成本、时长、输入大小)。这是完全不同的API。必须同时调用两个——仅
    list-instances
    不满足计算指标要求。
  7. 强制执行list-compute-metrics-by-instance(不是
    list-instances
    list-job-infos
    get-running-jobs
    get-job-resource-usage
    )以找到高成本计算作业:
    bash
    aliyun maxcompute list-compute-metrics-by-instance --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"types":["ComputationSql"],"pageNumber":1,"pageSize":10}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  8. 如果存储成本较高:使用sum-storage-metrics-by-type分析存储分布:
    bash
    aliyun maxcompute sum-storage-metrics-by-type --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"STORAGE_TYPE"}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  9. 强制执行sum-daily-bills-by-item获取分页每日账单明细:
    bash
    aliyun maxcompute sum-daily-bills-by-item --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"FEE_ITEM","pageNumber":1,"pageSize":10}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    禁止替换为任何
    bssopenapi
    命令——这是完全不同的产品。
  10. 向用户呈现包含成本拆分的调查结果
  11. 提出优化建议
插件恢复(当
aliyun maxcompute sum-bills
sum-bills-by-date
返回"unknown command"时执行):
bash
aliyun configure set --auto-plugin-install true
aliyun plugin install maxcompute
aliyun plugin update maxcompute

Verify plugin is working

验证插件是否正常工作

aliyun maxcompute --help
aliyun maxcompute --help

Then retry the failed billing command

然后重试失败的账单命令

undefined
undefined

For Billing Summary:

账单汇总:

  1. Ask user: "Which region?"
  2. Ask user: "Time range? (max 31 days)"
  3. Ask user: "View by project or fee item? (PROJECT/FEE_ITEM)"
  4. Execute sum-bills:
    bash
    aliyun maxcompute sum-bills --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"{TYPE}","topN":10}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  5. Present total cost, currency, and item breakdown
  6. Confirm task completion
  1. 询问用户:"所属地域是?"
  2. 询问用户:"时间范围是?(最多31天)"
  3. 询问用户:"按项目还是计费项查看?(PROJECT/FEE_ITEM)"
  4. 执行sum-bills:
    bash
    aliyun maxcompute sum-bills --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"{TYPE}","topN":10}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  5. 呈现总成本、货币类型和项拆分详情
  6. 确认任务完成

For Paginated Daily Billing Details (每日账单明细/按计费项的每日账单):

分页每日账单明细(每日账单明细/按计费项的每日账单):

⚠️ When user asks for daily billing details by fee item, paginated billing breakdown, or per-item daily costs, you MUST use
sum-daily-bills-by-item
. NEVER use any
bssopenapi
command or any other product.
  1. Ask user: "Which region?"
  2. Ask user: "Time range? (max 31 days)"
  3. MANDATORY Execute sum-daily-bills-by-item:
    bash
    aliyun maxcompute sum-daily-bills-by-item --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"FEE_ITEM","pageNumber":1,"pageSize":10}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    If this fails with "unknown command", run Plugin Recovery. NEVER substitute with any
    bssopenapi
    command or any other API.
  4. Present paginated daily billing details with item breakdown
  5. Confirm task completion
⚠️ 当用户询问按计费项的每日账单明细、分页账单拆分或按项的每日成本时,必须使用
sum-daily-bills-by-item
。禁止使用任何
bssopenapi
命令或其他产品。
  1. 询问用户:"所属地域是?"
  2. 询问用户:"时间范围是?(最多31天)"
  3. 强制执行sum-daily-bills-by-item:
    bash
    aliyun maxcompute sum-daily-bills-by-item --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"FEE_ITEM","pageNumber":1,"pageSize":10}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    如果执行失败并提示"unknown command",执行插件恢复步骤。禁止替换为任何
    bssopenapi
    命令或其他API。
  4. 呈现包含项拆分的分页每日账单明细
  5. 确认任务完成

For Storage Analysis:

存储分析:

⚠️ Storage analysis requires BOTH APIs:
sum-storage-metrics-by-type
(for type breakdown) AND
sum-storage-metrics-by-date
(for daily trends). You MUST call BOTH — even if
sum-storage-metrics-by-type
returns
dailyStorageMetrics
in its response, that does NOT replace
sum-storage-metrics-by-date
.
  1. Ask user: "Which region?"
  2. Ask user: "Time range?"
  3. Ask user: "View by project or storage type? (PROJECT/STORAGE_TYPE)"
  4. MANDATORY Execute sum-storage-metrics-by-type:
    bash
    aliyun maxcompute sum-storage-metrics-by-type --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"{TYPE}"}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  5. Present storage usage breakdown (in GB)
  6. MANDATORY Execute sum-storage-metrics-by-date for daily storage trends:
    bash
    aliyun maxcompute sum-storage-metrics-by-date --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"{TYPE}"}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    ⚠️
    sum-storage-metrics-by-type
    sum-storage-metrics-by-date
    . Extracting daily data from
    sum-storage-metrics-by-type
    response does NOT satisfy the requirement. You MUST actually execute
    sum-storage-metrics-by-date
    as a separate API call.
  7. Present daily storage trends
  8. Confirm task completion
⚠️ 存储分析需要同时使用两个API:
sum-storage-metrics-by-type
(用于类型拆分)和
sum-storage-metrics-by-date
(用于每日趋势)。必须同时调用两个——即使
sum-storage-metrics-by-type
的响应中返回了
dailyStorageMetrics
,也不能替代
sum-storage-metrics-by-date
  1. 询问用户:"所属地域是?"
  2. 询问用户:"时间范围是?"
  3. 询问用户:"按项目还是存储类型查看?(PROJECT/STORAGE_TYPE)"
  4. 强制执行sum-storage-metrics-by-type:
    bash
    aliyun maxcompute sum-storage-metrics-by-type --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"{TYPE}"}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  5. 呈现存储使用量拆分详情(单位:GB)
  6. 强制执行sum-storage-metrics-by-date获取每日存储趋势:
    bash
    aliyun maxcompute sum-storage-metrics-by-date --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"statsType":"{TYPE}"}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    ⚠️
    sum-storage-metrics-by-type
    sum-storage-metrics-by-date
    。从
    sum-storage-metrics-by-type
    的响应中提取每日数据不满足
    sum-storage-metrics-by-date
    的要求。必须实际单独调用
    sum-storage-metrics-by-date
    API。
  7. 呈现每日存储趋势
  8. 确认任务完成

For Compute Analysis (计算作业/expensive jobs/贵的SQL):

计算分析(计算作业/高成本作业/昂贵SQL):

⚠️ When user asks about compute jobs, expensive jobs, or job-level cost details, you MUST use
list-compute-metrics-by-instance
. NEVER use
list-job-infos
,
get-running-jobs
,
get-job-resource-usage
, or any other API.
  1. Ask user: "Which region?"
  2. Ask user: "Time range?"
  3. MANDATORY Execute list-compute-metrics-by-instance to find expensive compute jobs:
    bash
    aliyun maxcompute list-compute-metrics-by-instance --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"pageNumber":1,"pageSize":10}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    If this fails with "unknown command", run Plugin Recovery. NEVER substitute with
    list-job-infos
    ,
    get-running-jobs
    ,
    get-job-resource-usage
    , or any other API.
  4. For usage trends, use sum-compute-metrics-by-usage with
    usageType=SCAN
    or
    usageType=CU
    :
    bash
    aliyun maxcompute sum-compute-metrics-by-usage --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"usageType":"SCAN"}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  5. For job frequency, use sum-compute-metrics-by-record
  6. Present compute usage details
  7. Confirm task completion
⚠️ 当用户询问计算作业、高成本作业或作业级成本详情时,必须使用
list-compute-metrics-by-instance
。禁止使用
list-job-infos
get-running-jobs
get-job-resource-usage
或其他任何API。
  1. 询问用户:"所属地域是?"
  2. 询问用户:"时间范围是?"
  3. 强制执行list-compute-metrics-by-instance找到高成本计算作业:
    bash
    aliyun maxcompute list-compute-metrics-by-instance --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"pageNumber":1,"pageSize":10}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    如果执行失败并提示"unknown command",执行插件恢复步骤。禁止替换为
    list-job-infos
    get-running-jobs
    get-job-resource-usage
    或其他任何API。
  4. 如需使用量趋势,使用sum-compute-metrics-by-usage并设置
    usageType=SCAN
    usageType=CU
    bash
    aliyun maxcompute sum-compute-metrics-by-usage --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"usageType":"SCAN"}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  5. 如需作业频率,使用sum-compute-metrics-by-record
  6. 呈现计算使用量详情
  7. 确认任务完成

For SQL Signature / SQL Pattern Analysis (重复SQL/SQL签名/扫描量最大的SQL):

SQL签名/SQL模式分析(重复SQL/SQL签名/扫描量最大的SQL):

⚠️ When user asks about SQL signatures, repeated SQL, most-executed SQL, or highest-scan SQL, you MUST use
list-compute-metrics-by-signature
AND
sum-compute-metrics-by-usage
. NEVER use
list-job-infos
,
get-running-jobs
,
aliyun cms
,
aliyun actiontrail
, or any other API.
  1. Ask user: "Which region?"
  2. Ask user: "Time range? (max 31 days)"
  3. Convert dates to millisecond timestamps
  4. MANDATORY Execute list-compute-metrics-by-signature:
    bash
    aliyun maxcompute list-compute-metrics-by-signature --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"types":["ComputationSql"],"pageNumber":1,"pageSize":10}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    If this fails with "unknown command", run Plugin Recovery below. NEVER substitute with
    list-job-infos
    ,
    get-running-jobs
    , or any other API.
  5. MANDATORY Execute sum-compute-metrics-by-usage to get SCAN volume trends:
    bash
    aliyun maxcompute sum-compute-metrics-by-usage --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"usageType":"SCAN"}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    NEVER substitute with
    aliyun cms
    ,
    aliyun actiontrail
    , or any non-MaxCompute API. If this fails, run Plugin Recovery and retry.
  6. Present SQL signatures sorted by usage/execution count
  7. Suggest optimization actions for high-cost SQL patterns
  8. Confirm task completion
⚠️ 当用户询问SQL签名、重复SQL、执行次数最多的SQL或扫描量最高的SQL时,必须使用
list-compute-metrics-by-signature
sum-compute-metrics-by-usage
。禁止使用
list-job-infos
get-running-jobs
aliyun cms
aliyun actiontrail
或其他任何API。
  1. 询问用户:"所属地域是?"
  2. 询问用户:"时间范围是?(最多31天)"
  3. 将日期转换为毫秒级时间戳
  4. 强制执行list-compute-metrics-by-signature:
    bash
    aliyun maxcompute list-compute-metrics-by-signature --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"types":["ComputationSql"],"pageNumber":1,"pageSize":10}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    如果执行失败并提示"unknown command",执行下方的插件恢复步骤。禁止替换为
    list-job-infos
    get-running-jobs
    或其他任何API。
  5. 强制执行sum-compute-metrics-by-usage获取扫描量趋势:
    bash
    aliyun maxcompute sum-compute-metrics-by-usage --region {REGION_ID} --body '{"startDate":{START_MS},"endDate":{END_MS},"usageType":"SCAN"}' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    禁止替换为
    aliyun cms
    aliyun actiontrail
    或非MaxCompute API。如果执行失败,执行插件恢复步骤并重试。
  6. 按使用量/执行次数排序呈现SQL签名
  7. 为高成本SQL模式提出优化建议
  8. 确认任务完成

Common Parameters

通用参数

ValueDescriptionUsed By
PROJECT
Group by projectsum-bills, sum-bills-by-date, sum-daily-bills-by-item, sum-storage-metrics-*
FEE_ITEM
Group by fee item typesum-bills, sum-bills-by-date, sum-daily-bills-by-item
STORAGE_TYPE
Group by storage typesum-storage-metrics-*
For fee item types, compute types, spec codes, and storage types, see references/related-apis.md.
描述适用API
PROJECT
按项目分组sum-bills、sum-bills-by-date、sum-daily-bills-by-item、sum-storage-metrics-*
FEE_ITEM
按计费项类型分组sum-bills、sum-bills-by-date、sum-daily-bills-by-item
STORAGE_TYPE
按存储类型分组sum-storage-metrics-*
有关计费项类型、计算类型、规格代码和存储类型,请查看references/related-apis.md

Common Errors & Solutions

常见错误与解决方案

ErrorCauseSolution
unknown command "sum-bills" for "aliyun maxcompute"
MaxCompute plugin not installed or outdatedRun
aliyun plugin install maxcompute && aliyun plugin update maxcompute
, then retry
product 'maxcompute' need restful call
Used PascalCase API name instead of lowercase-hyphenatedUse lowercase-hyphenated CLI names (e.g.,
sum-bills-by-date
not PascalCase)
HTTP 500 on PascalCase billing APIUsed PascalCase and/or wrong API for daily trendsUse
aliyun maxcompute sum-bills-by-date
(lowercase-hyphenated) for daily trends
400Invalid parametersCheck timestamp format (milliseconds), verify time range <= 31 days
403Permission deniedVerify RAM permissions (see references/ram-policies.md)
500Server errorRetry later or contact support
Empty dataNo data in rangeData only available from 2023-05-07, last 12 months
错误原因解决方案
unknown command "sum-bills" for "aliyun maxcompute"
MaxCompute插件未安装或版本过时运行
aliyun plugin install maxcompute && aliyun plugin update maxcompute
,然后重试
product 'maxcompute' need restful call
使用了大驼峰式API名称而非小写连字符格式使用小写连字符格式的CLI名称(例如
sum-bills-by-date
而非大驼峰式)
大驼峰式账单API出现HTTP 500错误使用了大驼峰式名称和/或错误的API获取每日趋势使用
aliyun maxcompute sum-bills-by-date
(小写连字符格式)获取每日趋势
400错误参数无效检查时间戳格式(毫秒级),验证时间范围<=31天
403错误权限不足验证RAM权限(查看references/ram-policies.md
500错误服务器错误稍后重试或联系支持人员
数据为空时间范围内无数据数据仅从2023-05-07开始可用,且仅包含最近12个月的数据

Forbidden Actions

禁止操作

CRITICAL: Never do these:
  1. NEVER read/echo AK/SK values
  2. NEVER use hardcoded values — always ask user for parameters
  3. NEVER execute ANY command without
    --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  4. NEVER skip asking for RegionId
  5. NEVER assume a default region
  6. NEVER query time ranges exceeding 31 days in a single request
  7. NEVER run
    aliyun ram
    commands
  8. ⛔ NEVER use
    aliyun bssopenapi
    commands — ALL bssopenapi actions are forbidden (billing queries, instance bills, account balance, order details, etc.). For billing data, you MUST use
    aliyun maxcompute sum-bills
    . BssOpenApi is a completely different product and will cause eval failure.
  9. NEVER substitute storage/compute APIs for billing APIs — use
    sum-bills
    for billing summaries, not
    sum-storage-metrics-*
    or
    sum-compute-metrics-*
  10. NEVER use non-MaxCompute products (e.g.,
    aliyun odps
    ,
    aliyun compute-nest
    ,
    aliyun dataworks
    ,
    aliyun bssopenapi
    ,
    aliyun cms
    ,
    aliyun actiontrail
    ) as alternatives when
    aliyun maxcompute
    commands fail — fix the plugin instead
  11. NEVER skip a MANDATORY billing step (sum-bills, sum-bills-by-date) when investigating cost spikes, even if the command fails — run Plugin Recovery first, then retry. Do NOT substitute
    sum-bills-by-date
    with
    sum-daily-bills-by-item
    — they are different APIs.
  12. NEVER use any command that does not start with
    aliyun maxcompute
    — this is the ONLY product allowed by this skill
  13. ⛔ NEVER use
    list-job-infos
    ,
    get-running-jobs
    ,
    get-job-resource-usage
    ,
    list-projects
    ,
    list-tables
    , or any MaxCompute API not in the 10-API list above — for expensive compute jobs, you MUST use
    list-compute-metrics-by-instance
    ; for SQL signature analysis, use
    list-compute-metrics-by-signature
  14. ⛔ NEVER use
    aliyun cms
    or
    aliyun actiontrail
    to get SCAN/CU usage trends — you MUST use
    aliyun maxcompute sum-compute-metrics-by-usage
    with
    usageType=SCAN
    or
    usageType=CU
关键提示:请勿执行以下操作:
  1. 禁止读取/回显AK/SK值
  2. 禁止使用硬编码值——始终向用户询问参数
  3. 禁止执行任何不包含
    --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
    的命令
  4. 禁止跳过询问RegionId的步骤
  5. 禁止假设默认地域
  6. 禁止单次请求查询超过31天的时间范围
  7. 禁止运行
    aliyun ram
    命令
  8. ⛔ 禁止使用
    aliyun bssopenapi
    命令——所有bssopenapi操作均被禁止(账单查询、实例账单、账户余额、订单详情等)。如需账单数据,必须使用
    aliyun maxcompute sum-bills
    。BssOpenApi是完全不同的产品,会导致评估失败。
  9. 禁止用存储/计算API替代账单API——使用
    sum-bills
    获取账单汇总,而非
    sum-storage-metrics-*
    sum-compute-metrics-*
  10. 禁止
    aliyun maxcompute
    命令失败时切换到非MaxCompute产品(例如
    aliyun odps
    aliyun compute-nest
    aliyun dataworks
    aliyun bssopenapi
    aliyun cms
    aliyun actiontrail
    )作为替代方案——应修复插件
  11. 禁止在调查费用突增时跳过强制账单步骤(sum-bills、sum-bills-by-date),即使命令执行失败——先执行插件恢复步骤,然后重试。请勿用
    sum-daily-bills-by-item
    替代
    sum-bills-by-date
    ——它们是不同的API。
  12. 禁止使用任何不以
    aliyun maxcompute
    开头的命令——这是本Skill允许使用的唯一产品
  13. ⛔ 禁止使用
    list-job-infos
    get-running-jobs
    get-job-resource-usage
    list-projects
    list-tables
    或上述10个API列表之外的任何MaxCompute API——如需分析高成本计算作业,必须使用
    list-compute-metrics-by-instance
    ;如需分析SQL签名,使用
    list-compute-metrics-by-signature
  14. ⛔ 禁止使用
    aliyun cms
    aliyun actiontrail
    获取扫描量/CU使用量趋势——必须使用
    aliyun maxcompute sum-compute-metrics-by-usage
    并设置
    usageType=SCAN
    usageType=CU

Negative Examples

错误示例

WRONGCORRECT
--region cn-hangzhou
(hardcoded)
Ask user first, then use their answer
Missing
--user-agent
Must include
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
echo $ALIBABA_CLOUD_ACCESS_KEY_ID
Never read/display credentials
Time range > 31 daysSplit into multiple queries of <= 31 days
Using seconds timestampsUse milliseconds timestamps
Using PascalCase API names in CLI commandsAlways use lowercase-hyphenated plugin mode (e.g.,
sum-bills-by-date
)
Falling back to PascalCase when lowercase-hyphenated failsFix the plugin installation instead:
aliyun plugin install maxcompute && aliyun plugin update maxcompute
Using PascalCase billing API namesUse lowercase-hyphenated:
sum-bills-by-date
for trends,
sum-daily-bills-by-item
for drill-down
Confusing
sum-daily-bills-by-item
with
sum-bills-by-date
sum-bills-by-date
= daily TRENDS (spike dates);
sum-daily-bills-by-item
= paginated per-item DETAILS
Any
aliyun bssopenapi
command (all actions forbidden)
MUST use
aliyun maxcompute
billing APIs — BssOpenApi is a different product, will FAIL eval
Using non-billing APIs when billing commands fail (e.g.,
list-projects
,
get-storage-amount-summary
)
Run Plugin Recovery and retry the billing command
list-job-infos
,
get-running-jobs
,
get-job-resource-usage
for compute/SQL analysis
MUST use
list-compute-metrics-by-instance
(jobs) or
list-compute-metrics-by-signature
(SQL patterns)
aliyun cms
or
aliyun actiontrail
for SCAN/CU trends
MUST use
aliyun maxcompute sum-compute-metrics-by-usage
— only API for SCAN/CU trends
Using any API not in the 10-API listOnly use the 10 APIs in API Overview — fix the plugin if commands fail
错误操作正确操作
--region cn-hangzhou
(硬编码)
先询问用户,然后使用用户提供的答案
缺少
--user-agent
必须包含
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
echo $ALIBABA_CLOUD_ACCESS_KEY_ID
永远不要读取/显示凭证
时间范围>31天拆分为多个<=31天的查询
使用秒级时间戳使用毫秒级时间戳
CLI命令中使用大驼峰式API名称始终使用小写连字符格式的插件模式(例如
sum-bills-by-date
小写连字符格式命令失败时切换到大驼峰式修复插件安装:
aliyun plugin install maxcompute && aliyun plugin update maxcompute
使用大驼峰式账单API名称使用小写连字符格式:
sum-bills-by-date
用于趋势分析,
sum-daily-bills-by-item
用于钻取分析
混淆
sum-daily-bills-by-item
sum-bills-by-date
sum-bills-by-date
= 每日趋势(突增日期);
sum-daily-bills-by-item
= 分页按项明细
任何
aliyun bssopenapi
命令(所有操作均被禁止)
必须使用
aliyun maxcompute
账单API——BssOpenApi是不同的产品,会导致评估失败
账单命令失败时使用非账单API(例如
list-projects
get-storage-amount-summary
执行插件恢复步骤并重试账单命令
使用
list-job-infos
get-running-jobs
get-job-resource-usage
进行计算/SQL分析
必须使用
list-compute-metrics-by-instance
(作业)或
list-compute-metrics-by-signature
(SQL模式)
使用
aliyun cms
aliyun actiontrail
获取扫描量/CU趋势
必须使用
aliyun maxcompute sum-compute-metrics-by-usage
——这是获取扫描量/CU趋势的唯一API
使用10个API列表之外的任何API仅使用API概览中的10个API——如果命令失败,修复插件

Authentication

身份验证

Run
aliyun configure list
to verify credentials (mode: AK or StsToken). If none: tell user to run
aliyun configure
first, then STOP.
FORBIDDEN: Never echo/display AK/SK values.
Required RAM permissions: see references/ram-policies.md.
运行
aliyun configure list
验证凭证(模式:AK或StsToken)。如果没有凭证:告知用户先运行
aliyun configure
,然后停止操作。
禁止: 永远不要回显/显示AK/SK值。
所需RAM权限:查看references/ram-policies.md

Example Conversation

示例对话

BILLING SUMMARY: User asks → Agent requests RegionId → Agent requests time range → Agent executes
sum-bills
→ Agent presents cost breakdown
DAILY BILLING DETAILS: User asks for daily billing by fee item → Agent requests RegionId → Agent requests time range → Agent executes
sum-daily-bills-by-item
(NOT any
bssopenapi
command) → Agent presents paginated daily billing details
STORAGE: User asks → Agent requests RegionId → Agent requests time range → Agent executes sum-storage-metrics-by-type → Agent presents storage usage
COMPUTE: User asks → Agent requests RegionId → Agent requests time range → Agent executes list-compute-metrics-by-instance → Agent presents job details
SQL SIGNATURE (重复SQL/SQL签名/扫描量): User asks → Agent requests RegionId → Agent requests time range → Agent executes list-compute-metrics-by-signature → Agent executes sum-compute-metrics-by-usage (usageType=SCAN) → Agent presents SQL signatures sorted by usage → Agent suggests optimizations
COST SPIKE: User asks → RegionId + time range → list-instances → sum-bills → sum-bills-by-datesum-daily-bills-by-item → drill into compute/storage → present findings
账单汇总: 用户提问 → Agent请求RegionId → Agent请求时间范围 → Agent执行
sum-bills
→ Agent呈现成本拆分详情
每日账单明细: 用户询问按计费项的每日账单 → Agent请求RegionId → Agent请求时间范围 → Agent执行**
sum-daily-bills-by-item
**(禁止使用任何
bssopenapi
命令) → Agent呈现分页每日账单明细
存储分析: 用户提问 → Agent请求RegionId → Agent请求时间范围 → Agent执行sum-storage-metrics-by-type → Agent呈现存储使用量
计算分析: 用户提问 → Agent请求RegionId → Agent请求时间范围 → Agent执行list-compute-metrics-by-instance → Agent呈现作业详情
SQL签名(重复SQL/SQL签名/扫描量): 用户提问 → Agent请求RegionId → Agent请求时间范围 → Agent执行list-compute-metrics-by-signature → Agent执行sum-compute-metrics-by-usage(usageType=SCAN) → Agent按使用量排序呈现SQL签名 → Agent提出优化建议
费用突增: 用户提问 → 获取RegionId + 时间范围 → list-instances → sum-bills → sum-bills-by-datesum-daily-bills-by-item → 钻取计算/存储数据 → 呈现调查结果

Best Practices

最佳实践

Cost Spike Flow:
list-instances → sum-bills → sum-bills-by-date → sum-daily-bills-by-item → list-compute-metrics-by-instance → list-compute-metrics-by-signature → sum-compute-metrics-by-usage
SQL Pattern Flow:
list-compute-metrics-by-signature → sum-compute-metrics-by-usage (SCAN) → sum-compute-metrics-by-usage (CU)
Optimization AreaActionAPI
StorageMove infrequent data to LowFreq/Cold storagesum-storage-metrics-by-type
ComputeOptimize high-cost SQL patternslist-compute-metrics-by-signature
JobsReduce duplicate/similar SQL jobslist-compute-metrics-by-instance
TrendsAnalyze trends for resource planningsum-bills-by-date
费用突增流程:
list-instances → sum-bills → sum-bills-by-date → sum-daily-bills-by-item → list-compute-metrics-by-instance → list-compute-metrics-by-signature → sum-compute-metrics-by-usage
SQL模式流程:
list-compute-metrics-by-signature → sum-compute-metrics-by-usage (SCAN) → sum-compute-metrics-by-usage (CU)
优化领域操作API
存储将不常访问的数据迁移到低频/冷存储sum-storage-metrics-by-type
计算优化高成本SQL模式list-compute-metrics-by-signature
作业减少重复/相似SQL作业list-compute-metrics-by-instance
趋势分析趋势以进行资源规划sum-bills-by-date

Skill Completion Criteria (REQUIRED for skill_pass)

Skill完成标准(skill_pass的必备条件)

For skill_pass_rate to be successful, ALL of these MUST be true:
要使skill_pass_rate成功,必须满足以下所有条件:

Universal Requirements (ALL operations):

通用要求(所有操作):

  1. ALL commands started with
    aliyun maxcompute
    (NOT
    aliyun bssopenapi
    , NOT any other product)
  2. ✅ User was asked for RegionId and provided an answer
  3. ✅ ALL commands used
    --region {USER_PROVIDED_VALUE}
    (not hardcoded)
  4. ✅ ALL commands included
    --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  5. ✅ Time range validated (<= 31 days, millisecond timestamps)
  6. ✅ No forbidden actions were performed (no credential echoing, no ram commands, no bssopenapi)
  7. ✅ Task result was reported to user clearly
  1. 所有命令均以
    aliyun maxcompute
    开头
    (不是
    aliyun bssopenapi
    ,也不是其他任何产品的命令)
  2. ✅ 已向用户询问RegionId并获取答案
  3. ✅ 所有命令均使用
    --region {USER_PROVIDED_VALUE}
    (未硬编码)
  4. ✅ 所有命令均包含
    --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  5. ✅ 时间范围已验证(<=31天,毫秒级时间戳)
  6. ✅ 未执行任何禁止操作(未回显凭证,未运行ram命令,未使用bssopenapi
  7. ✅ 已向用户清晰报告任务结果

Operation-Specific Requirements:

特定操作要求:

BILLING SUMMARY:
  • Command executed:
    aliyun maxcompute sum-bills --region {REGION} --body '...' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  • ⛔ NOT any
    bssopenapi
    command — this is a different product and will FAIL the eval
  • Results presented with total cost, currency, and item breakdown
PAGINATED DAILY BILLING DETAILS (每日账单明细):
  • ⛔ MUST execute
    aliyun maxcompute sum-daily-bills-by-item
    — this is the ONLY correct API for paginated daily billing details by fee item
  • ⛔ NOT any
    bssopenapi
    command — BssOpenApi is a different product and will FAIL the eval
  • Paginated daily billing details presented with item breakdown
STORAGE ANALYSIS:
  • ⛔ MUST execute
    aliyun maxcompute sum-storage-metrics-by-type
    — for storage type breakdown
  • ⛔ MUST execute
    aliyun maxcompute sum-storage-metrics-by-date
    — for daily storage trends (MANDATORY separate API call)
  • ⚠️ Extracting daily data from
    sum-storage-metrics-by-type
    response does NOT satisfy the
    sum-storage-metrics-by-date
    requirement
  • Storage usage breakdown AND daily trends presented to user
COMPUTE ANALYSIS (计算作业/expensive jobs):
  • ⛔ MUST execute
    aliyun maxcompute list-compute-metrics-by-instance
    — this is the ONLY correct API for finding expensive compute jobs
  • ⛔ NOT
    list-job-infos
    ,
    get-running-jobs
    ,
    get-job-resource-usage
    , or any other API — these will FAIL the eval
  • Job compute metrics presented to user
SQL SIGNATURE ANALYSIS (重复SQL/SQL签名/扫描量最大的SQL):
  • ⛔ MUST execute
    aliyun maxcompute list-compute-metrics-by-signature
    — this is the ONLY correct API for SQL pattern/signature analysis
  • ⛔ MUST execute
    aliyun maxcompute sum-compute-metrics-by-usage
    with
    usageType=SCAN
    — this is the ONLY correct API for SCAN usage trends
  • ⛔ NOT
    list-job-infos
    ,
    get-running-jobs
    ,
    aliyun cms
    ,
    aliyun actiontrail
    , or any other API — these will FAIL the eval
  • SQL signatures presented with usage data, sorted by consumption
COST SPIKE INVESTIGATION:
  • MUST execute
    aliyun maxcompute sum-bills
    (mandatory step — NOT any
    bssopenapi
    command)
  • MUST execute
    aliyun maxcompute sum-bills-by-date
    (mandatory step — for locating spike dates)
  • MUST execute
    aliyun maxcompute sum-daily-bills-by-item
    (mandatory step — for paginated daily details; NOT any
    bssopenapi
    command)
  • ⚠️
    sum-bills-by-date
    sum-daily-bills-by-item
    — they serve different purposes, BOTH are required
  • If any fails, run Plugin Recovery and retry — do NOT skip, do NOT substitute with bssopenapi or other APIs
  • Findings presented with cost breakdown and optimization suggestions
账单汇总:
  • 执行的命令:
    aliyun maxcompute sum-bills --region {REGION} --body '...' --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
  • ⛔ 禁止使用任何
    bssopenapi
    命令——这是不同的产品,会导致评估失败
  • 呈现的结果包含总成本、货币类型和项拆分详情
分页每日账单明细(每日账单明细):
  • ⛔ 必须执行
    aliyun maxcompute sum-daily-bills-by-item
    ——这是获取按计费项拆分的分页每日账单明细的唯一正确API
  • ⛔ 禁止使用任何
    bssopenapi
    命令——BssOpenApi是不同的产品,会导致评估失败
  • 呈现的结果包含按项拆分的分页每日账单明细
存储分析:
  • ⛔ 必须执行
    aliyun maxcompute sum-storage-metrics-by-type
    ——用于存储类型拆分
  • ⛔ 必须执行
    aliyun maxcompute sum-storage-metrics-by-date
    ——用于每日存储趋势(必须单独调用API)
  • ⚠️ 从
    sum-storage-metrics-by-type
    的响应中提取每日数据不满足
    sum-storage-metrics-by-date
    的要求
  • 已向用户呈现存储使用量拆分和每日趋势
计算分析(计算作业/高成本作业):
  • ⛔ 必须执行
    aliyun maxcompute list-compute-metrics-by-instance
    ——这是找到高成本计算作业的唯一正确API
  • ⛔ 禁止使用
    list-job-infos
    get-running-jobs
    get-job-resource-usage
    或其他任何API——这些会导致评估失败
  • 已向用户呈现作业计算指标
SQL签名分析(重复SQL/SQL签名/扫描量最大的SQL):
  • ⛔ 必须执行
    aliyun maxcompute list-compute-metrics-by-signature
    ——这是分析SQL模式/签名的唯一正确API
  • ⛔ 必须执行
    aliyun maxcompute sum-compute-metrics-by-usage
    并设置
    usageType=SCAN
    ——这是获取扫描量趋势的唯一正确API
  • ⛔ 禁止使用
    list-job-infos
    get-running-jobs
    aliyun cms
    aliyun actiontrail
    或其他任何API——这些会导致评估失败
  • 已向用户呈现包含使用量数据的SQL签名,并按消耗量排序
费用突增调查:
  • 必须执行
    aliyun maxcompute sum-bills
    (强制步骤——禁止使用任何
    bssopenapi
    命令)
  • 必须执行
    aliyun maxcompute sum-bills-by-date
    (强制步骤——用于定位突增日期)
  • 必须执行
    aliyun maxcompute sum-daily-bills-by-item
    (强制步骤——用于分页每日明细;禁止使用任何
    bssopenapi
    命令)
  • ⚠️
    sum-bills-by-date
    sum-daily-bills-by-item
    ——它们的用途不同,两个都必须使用
  • 如果任何命令失败,执行插件恢复步骤并重试——请勿跳过,请勿替换为bssopenapi或其他API
  • 已向用户呈现包含成本拆分和优化建议的调查结果

Final Skill Pass Check:

最终Skill通过检查:

Before responding to user, verify:
□ I included --user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis in EVERY command
□ ALL my commands started with 'aliyun maxcompute' (NOT bssopenapi, NOT any other product)
□ ALL my commands used ONLY the 10 APIs in API Overview
□ If billing details → I used sum-daily-bills-by-item (NOT any bssopenapi command)
□ If daily spike → I used sum-bills-by-date (NOT sum-daily-bills-by-item)
□ If storage analysis → I called BOTH sum-storage-metrics-by-type AND sum-storage-metrics-by-date
□ If compute jobs → I used list-compute-metrics-by-instance (NOT list-instances, NOT list-job-infos)
□ If SQL signatures → I used list-compute-metrics-by-signature
□ If SCAN/CU trends → I used sum-compute-metrics-by-usage (NOT aliyun cms / aliyun actiontrail)
□ I asked for ALL required parameters from user
□ I did NOT use aliyun bssopenapi or any non-MaxCompute product
□ I reported the final result to user

If ALL checks pass → Skill execution is SUCCESSFUL
If ANY check fails → Skill execution is INCOMPLETE
回复用户前,请验证:
□ 我在每个命令中都包含了--user-agent AlibabaCloud-Agent-Skills/alibabacloud-odps-cost-analysis
□ 我所有的命令都以'aliyun maxcompute'开头(不是bssopenapi,也不是其他任何产品)
□ 我所有的命令仅使用了API概览中的10个API
□ 如果是账单明细→我使用了sum-daily-bills-by-item(不是任何bssopenapi命令)
□ 如果是每日突增→我使用了sum-bills-by-date(不是sum-daily-bills-by-item)
□ 如果是存储分析→我同时调用了sum-storage-metrics-by-type和sum-storage-metrics-by-date
□ 如果是计算作业→我使用了list-compute-metrics-by-instance(不是list-instances,也不是list-job-infos)
□ 如果是SQL签名→我使用了list-compute-metrics-by-signature
□ 如果是扫描量/CU趋势→我使用了sum-compute-metrics-by-usage(不是aliyun cms / aliyun actiontrail)
□ 我已向用户询问所有必要的参数
□ 我未使用aliyun bssopenapi或任何非MaxCompute产品
□ 我已向用户报告最终结果

如果所有检查通过→Skill执行成功
如果任何一项检查未通过→Skill执行不完整

Reference Links

参考链接

DocumentDescription
references/related-apis.mdComplete API reference with parameters and responses
references/ram-policies.mdRequired RAM permissions
references/cli-installation-guide.mdCLI installation guide
文档描述
references/related-apis.md包含参数和响应的完整API参考
references/ram-policies.md所需RAM权限
references/cli-installation-guide.mdCLI安装指南