Cost analysis

From microsoft/sre-agent · View interactive version

Cost analysis is an AI agent skill from the GitHub repository microsoft/sre-agent. Use when an operator or a scheduled task requests a periodic cloud-cost / spend audit of the Zava Learning resource group — identify the top cost drivers, week-over-week trend, idle or oversized resources, and concrete savings opportunities. Read-only; produces findings for a report.

How to use this skill

Skill file

Zava Learning — Cloud Cost Analysis

Resource Group: @@RG@@. Read-only audit — never resize, deallocate, or delete a resource.

This is a weekly spend posture review. Recommend optimisations for a human to apply; change nothing.

1. Pull actual spend (preferred path)

Use Cost Management for real billed amounts, scoped to the RG:

`az costmanagement query --type ActualCost --timeframe Custom --time-period from=<start> to=<end>

--scope "/subscriptions/<sub>/resourceGroups/@@RG@@"

--dataset-grouping name=ResourceId type=Dimension --dataset-aggregation totalCost.name=Cost totalCost.function=Sum`

(run it for the current 7-day window and the prior 7-day window, then diff per ResourceId).

If az costmanagement is missing or returns an auth error (the agent identity lacks **Cost

Management Reader**), FALL BACK to az consumption usage list --start-date <d> --end-date <d>

filtered to the RG. Record which data source you used so the report is honest about provenance.

2. If billing data is unavailable, estimate from inventory

As a last resort (no Cost Management and no consumption access), build an estimate:

disks, Container Apps environments + per-app replicas/scale, Application Gateway tier + capacity

units, Log Analytics ingestion, Key Vault, ACR SKU, public IPs).

clearly-labelled estimate*, not a billed figure. State the assumption explicitly.

3. Find waste and right-sizing opportunities (read-only signals)

any VM (az disk list -g @@RG@@ --query "[?managedBy==null]"); over-provisioned VM/DB SKUs vs.

observed CPU/memory; Container Apps with high min-replicas but low traffic.

4. Produce the findings table

For each driver/opportunity output a row: `Resource (type) · This week $ · Last week $ · Δ% ·

Finding · Severity · Recommendation`. Severity is impact-based: a sharp WoW spike or a clearly idle/

oversized paid resource is SEV2; smaller tidy-ups are SEV3. Sort by this-week spend (and severity).

Also produce a posture summary (total RG spend this week, WoW delta, the single biggest saving) and a

prioritized recommendations list with rough monthly savings where you can estimate them.

5. Hand off to the branded report

This skill does not remediate. Pass the posture summary, the findings rows (each with its severity),

the spend numbers, and the recommendations to the zava-audit-report skill, which renders the single

branded, downloadable PowerPoint deck (top cost drivers chart + findings table) and returns its

download link. Surface that link to the operator.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.