← 返回 Skills 市场
1w2w3y

AMG Azure Subscription Cost Analysis

作者 1w2w3y · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
56
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install amg-check-azure-spend
功能描述
Run only when the user explicitly asks for a monthly Azure subscription cost analysis — lists all accessible subscriptions, lets the user choose which to ana...
使用说明 (SKILL.md)

\x3C!-- Auto-generated for OpenClaw by pack-openclaw. Notes for OpenClaw users: - Claude Code dynamic expressions (!...) in this file are NOT evaluated by OpenClaw and appear as literal text. Run them manually at the start of the workflow. - Invoke this skill only via slash command (e.g. /amg-check-azure-spend). Auto-invocation is disabled on Claude Code but not on OpenClaw. -->

OpenClaw Setup (one-time)

This skill calls MCP tools prefixed with mcp__amg__*, so OpenClaw must have an MCP server registered under the exact name amg. Run this once per workspace before invoking the skill:

openclaw mcp set amg '{"url":"https://\x3Cyour-grafana-instance>/api/azure-mcp","transport":"streamable-http","headers":{"Authorization":"Bearer \x3Cyour-token>"}}'

Replace \x3Cyour-grafana-instance> with your Azure Managed Grafana endpoint and \x3Cyour-token> with a valid Grafana service-account token (starts with glsa_). The server name must be amg — the skill's allowed-tools reference mcp__amg__* and will not find tools under any other name.

Verify the server is registered:

openclaw mcp list

Official skill source: https://github.com/Azure/amg-skills

Runtime Context

  • Current UTC time: !date -u +%Y-%m-%dT%H:%M:%SZ
  • Config: !cat memory/amg-check-azure-spend/config.md 2>/dev/null || echo "NOT_CONFIGURED"
  • Arguments: subscription-ids=$ARGUMENTS

Azure Subscription Cost Analysis

Analyze Azure subscription costs for the last full billing month using amgmcp_cost_analysis. Queries each subscription individually with mandatory waits between calls to respect the billing API rate limit.

Critical Constraints

  • No subagents for MCP. The Agent tool cannot access MCP tools — all MCP calls must be made from the main context.
  • Sequential queries only. Query one subscription at a time. Never query multiple subscriptions in parallel.
  • Mandatory 1-minute wait. After each amgmcp_cost_analysis call, run sleep 60 via Bash before the next call. This is non-negotiable — the billing API has a tight rate limit.
  • Recommend 5 subscriptions per run. The billing API has tight throttling — each subscription takes 1-3 minutes (wait time + potential 429 retries). Warn the user if they select more than 5 that the run will be slow, but allow it if they confirm.
  • 429 backoff. If you receive a 429 (Too Many Requests), wait 2 minutes (sleep 120), then retry. If 429 persists, wait 5 minutes (sleep 300) and retry once more. If still failing, skip that subscription and note it in the report.

Progress Tracking

Update checkboxes as you complete each phase:

  • Phase 1a: Datasource validated
  • Phase 1b: Subscriptions listed
  • Phase 1c: Subscriptions selected
  • Phase 2: Cost queries completed (0/N)
  • Report presented
  • Report saved to memory/amg-check-azure-spend/report.md

Configuration

If Config shows NOT_CONFIGURED: Run First-Run Setup at the bottom of this file, then return here.

If Config is populated: Extract the datasource UID from the pre-loaded Runtime Context above.

  • Datasource UID: from ## Azure Monitor Datasource > UID

Time Range

Always use the last full billing month boundaries. Compute them from the "Current UTC time" in the Runtime Context above:

  • startTime: first day of the previous month at 00:00:00.000Z (e.g., if current UTC time is 2026-04-16T..., startTime = 2026-03-01T00:00:00.000Z)
  • endTime: first day of the current month at 00:00:00.000Z (e.g., if current UTC time is 2026-04-16T..., endTime = 2026-04-01T00:00:00.000Z)

Do NOT use relative expressions like now-30d — billing months have variable lengths.


Workflow

Phase 1a: Validate Datasource

Call amgmcp_datasource_list (no parameters). Find entry with type == "grafana-azure-monitor-datasource".

  • Matches configured UID -> proceed.
  • Different UID -> update memory/amg-check-azure-spend/config.md, warn user, use new UID.
  • Not found -> abort with error.

Phase 1b: List All Subscriptions

Call amgmcp_query_azure_subscriptions with the validated datasource UID.

Present the full list as a table:

# Subscription Name Subscription ID
1 ... ...

Phase 1c: Select Subscriptions

If $ARGUMENTS provides subscription IDs (comma-separated): Use those directly. Validate they appear in the Phase 1b list.

If 5 or fewer subscriptions exist: Use all of them.

If more than 5 subscriptions exist: Present the list to the user and ask them to choose. Suggest a default selection of ~5 based on name (e.g., production subscriptions first). Example prompt:

"Found N subscriptions. I recommend selecting around 5 — the billing API has tight rate limits, so each subscription takes 1-3 minutes (mandatory waits + potential 429 retries). You can select more, but the run will be slow. Which subscription numbers would you like to analyze? (e.g., 1,3,5) Or press Enter to use my suggested selection: [list]."

If the user selects more than 5: Warn them about the expected duration (roughly 2-3 minutes per subscription due to mandatory waits and 429 backoffs), then proceed if they confirm.

Phase 2: Query Cost for Each Subscription

For each selected subscription, one at a time:

  1. Call amgmcp_cost_analysis with:

    azureMonitorDatasourceUid: {DATASOURCE_UID}
    subscriptionId: {SUBSCRIPTION_ID}
    startTime: {BILLING_MONTH_START}
    endTime: {BILLING_MONTH_END}
    
  2. Record the cost breakdown from the response:

    • Total cost for the subscription
    • Top cost drivers by resource type (MeterCategory)
    • Cost by region
    • Any notable cost spikes or anomalies
  3. Wait 1 minute before the next query:

    sleep 60
    
  4. If you receive a 429 (Too Many Requests):

    • Wait 2 minutes: sleep 120
    • Retry the same subscription
    • If 429 again, wait 5 minutes: sleep 300 and retry once more
    • If still 429, skip this subscription and note "Rate-limited — skipped" in the report

Repeat for each subscription. Do NOT proceed to the next subscription without the 1-minute wait.


Output Format

Present a cost report with these sections:

1. Billing Period

State the exact billing month analyzed (e.g., "March 2026: 2026-03-01 to 2026-04-01").

2. Cost Summary Table

Subscription Total Cost Top Resource Type Top Region Status
sub-name-1 $X,XXX.XX Virtual Machines East US OK
sub-name-2 $X,XXX.XX Storage West US 2 OK

3. Per-Subscription Breakdown

For each subscription:

  • Total cost for the billing month
  • Top 10 cost drivers by MeterCategory (resource type) with amounts and percentages
  • Cost by region — table showing spend per Azure region
  • Notable observations — any unusually high costs, unexpected resource types, or potential optimization opportunities

4. Cross-Subscription Comparison

  • Which subscription has the highest spend
  • Common cost drivers across subscriptions
  • Regional distribution of spend across all queried subscriptions

5. Cost Optimization Suggestions

Based on the data, flag:

  • Subscriptions with disproportionately high costs in a single category
  • Resource types that dominate spend (potential right-sizing candidates)
  • Regions with unexpectedly high costs

Save Report

After presenting findings, save the report to memory/amg-check-azure-spend/report.md:

  1. Read the current file (if it exists).
  2. Overwrite with the full cost report from this run, including:
    • Billing period and generation date
    • Cost summary table across all queried subscriptions
    • Per-subscription breakdowns (top services, regions, resource types)
    • Cross-subscription comparison
    • Cost optimization suggestions
    • Any skipped subscriptions (rate-limited) noted with reason
  3. Update the "Generated" date header to today's date.

This file provides a baseline for future runs to compare month-over-month trends.


Error Handling

See ${CLAUDE_SKILL_DIR}/reference/error-handling.md for the full recovery table.


First-Run Setup

Run only when Config shows NOT_CONFIGURED. After completing, return to the Workflow above.

1. Discover Datasource UID: Call amgmcp_datasource_list. Filter type == "grafana-azure-monitor-datasource". Prefer uid == "azure-monitor-oob" if multiple match. Abort if zero match.

2. Write config: Write memory/amg-check-azure-spend/config.md:

# amg-check-azure-spend Configuration

User-specific values for the Azure spend analysis skill.
This file is auto-generated on first run and can be edited manually.

## Azure Monitor Datasource
- **UID**: {discovered_uid}
- **Name**: {discovered_name}

3. Confirm: Show the resolved config and ask for confirmation before proceeding.

安全使用建议
This skill appears to do what it says (query Azure billing via a Grafana/AMG MCP datasource) but requires you to register a Grafana/MCP server named exactly 'amg' and supply a Grafana service-account token via `openclaw mcp set` (the SKILL.md example uses a `glsa_...` token). That token gives access to your Grafana instance and its datasources — before configuring it, verify the token's scope and limit it to read-only access for the Azure Monitor datasource. Note the skill may run for many minutes if you select multiple subscriptions (mandatory 60s waits and backoff rules). Also: for very large results it may offer to invoke local interpreters (node/python/jq/pwsh) or Bash to parse/save data—those are optional but would execute local commands and should be approved only after review. Finally, the registry metadata does not list the Grafana token as a required credential; treat that as a documentation mismatch and, if possible, verify the skill source (SKILL.md claims an Azure GitHub repo) before provisioning credentials or running it in a production workspace. If you proceed, use a temporary or least-privilege token and test in an isolated workspace first.
功能分析
Type: OpenClaw Skill Name: amg-check-azure-spend Version: 1.0.0 The skill provides a legitimate utility for analyzing Azure subscription costs via an Azure Managed Grafana MCP server. It implements responsible API usage patterns, including sequential querying and mandatory 1-minute waits (`sleep 60`) to avoid rate limits, and includes detailed error handling for 429 (Too Many Requests) responses. While it requires a Grafana service token for setup, this is handled through standard MCP configuration, and the skill's logic is focused entirely on local report generation and data presentation without evidence of exfiltration or unauthorized execution.
能力评估
Purpose & Capability
The skill's name/description (Azure subscription cost analysis) aligns with the MCP calls and workflow in SKILL.md: it lists subscriptions and queries cost breakdowns via mcp__amg__* tools. However, the SKILL.md expects the workspace to be configured with a Grafana/MCP endpoint and a Grafana service-account token (glsa_...) via `openclaw mcp set`, but the registry metadata declares no required credentials/primary credential. That mismatch (needed token not listed in metadata) is a documentation/inventory inconsistency.
Instruction Scope
Instructions are explicit and scoped to listing datasources, enumerating subscriptions, and running cost-analysis calls with mandatory waits and 429 backoff. The skill reads/writes from its own memory path (memory/amg-check-azure-spend/*) and uses `date` to compute time ranges. Two caution points: (1) reference/error-handling.md says very large results may be parsed by invoking local interpreters (node, python, jq, pwsh) or running Bash; those are optional but could execute local code when used, and (2) the user must run `openclaw mcp set` to provide the Grafana token—this stores credentials in the workspace config outside the skill's declared env vars. No instructions send data to unexpected external endpoints other than the Grafana/MCP URL the user provides.
Install Mechanism
Instruction-only skill with no install spec and no code files. Lowest install risk: nothing is downloaded or written by an installer.
Credentials
The skill requires, in practice, a Grafana service-account token configured into OpenClaw's MCP registry (the SKILL.md demonstrates the `openclaw mcp set amg '{...Authorization: "Bearer <your-token>"}'` command). Yet the registry metadata lists no required env vars or primary credential. Requiring a workspace-stored Grafana token (which can allow read access to datasources and potentially more) without declaring it in the skill manifest is a proportionality/documentation mismatch. Users should ensure the token is least-privilege (read-only for the Azure Monitor datasource) before registering it.
Persistence & Privilege
The skill is not always-enabled, and model invocation is disabled (disable-model-invocation: true), so it cannot run autonomously. It writes reports to its own memory path (memory/amg-check-azure-spend/report.md), which is normal for a skill of this type. It does not request system-wide configuration changes or persistent privileges beyond storing its own config in workspace memory and the MCP registry entry the user creates.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install amg-check-azure-spend
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /amg-check-azure-spend 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release — provides monthly Azure subscription cost analysis with strict rate-limit handling. - Lists all accessible Azure subscriptions and lets users select analysis targets. - Fetches last billing month's cost breakdown by resource type, region, and service category for each subscription. - Uses a mandatory 1-minute wait between billing queries to prevent rate limiting; includes robust 429 (Too Many Requests) backoff logic. - Sequential processing only; recommends analyzing up to 5 subscriptions per run. - Outputs summary and detailed breakdowns, and saves a full report for reference.
元数据
Slug amg-check-azure-spend
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

AMG Azure Subscription Cost Analysis 是什么?

Run only when the user explicitly asks for a monthly Azure subscription cost analysis — lists all accessible subscriptions, lets the user choose which to ana... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 56 次。

如何安装 AMG Azure Subscription Cost Analysis?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install amg-check-azure-spend」即可一键安装,无需额外配置。

AMG Azure Subscription Cost Analysis 是免费的吗?

是的,AMG Azure Subscription Cost Analysis 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

AMG Azure Subscription Cost Analysis 支持哪些平台?

AMG Azure Subscription Cost Analysis 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 AMG Azure Subscription Cost Analysis?

由 1w2w3y(@1w2w3y)开发并维护,当前版本 v1.0.0。

💬 留言讨论