references/cost-investigation.md
Cost Investigation
Explain what changed before recommending remediation.
Establish the Baseline
- Confirm scope, anomaly window, currency, and whether the concern is a daily spike, sustained increase, or invoice-level change. Exclude an incomplete current day unless the user explicitly wants partial data.
- Call
query_costswith daily granularity for the anomaly and an equal-length baseline. Prefer comparable weekdays, billing-cycle position, and known seasonal or deployment periods over an arbitrary preceding window. - Request separate
granularity=Nonetotals for the anomaly and baseline; never sum daily rows in a shell or local interpreter. Calculate the absolute and percentage delta from those returned totals per currency. Keep actual and amortized cost separate; use amortized cost when commitment purchases could distort the usage trend.
Find the Driver
- Start with
ServiceName, rank by absolute delta, then narrow the leading service through separate bounded queries byResourceGroupName,ResourceId, andMeterwhere those dimensions are supported. Reuse exact values returned by the broader query instead of guessing filter values. - Query
ChargeTypeandPricingModelto distinguish recurring usage, purchases, refunds, credits, marketplace charges, and commitment effects. Do not attribute a shared or unallocated charge to one resource without evidence. - Prefer one billing-scope request over many subscription requests when the subscriptions share an accessible billing scope. Otherwise limit fan-out, sort by cost descending, and disclose partial results.
Correlate the Cause
- For the leading resources, query Resource Graph
resourcechangesaround the anomaly. Rungenerate_query,validate_query, thenexecute_query. Inspect creates, deletes, SKU or tier changes, scale events, region changes, and ownership-tag changes. - Correlate only evidence from matching resources and time windows. A change near a spike is a candidate cause, not proof. Resolve likely ownership from resource groups and the organization's actual owner or cost-allocation tags; tag names are case-sensitive.
- Classify the result as recurring or one-time and controllable or expected. Assign high confidence only when cost, resource, meter, and change evidence align. Use medium or low confidence when attribution is indirect.
Use the cost-query workflow for limits, pagination, query errors, and API fallback.
Report
Present:
- anomaly and baseline windows;
- absolute and percentage change per currency;
- leading service, resource group, resource, meter, charge type, and pricing model;
- correlated resource changes and likely owner;
- classification, confidence, evidence gaps, and one next action.
Change history is short-lived, and empty results can reflect retention, permissions, or unsupported attribution. Never treat missing evidence as proof that nothing changed.
Handoffs
- Overprovisioning or cleanup opportunity:
cost-optimization. - Reservation or Savings Plan change:
cost-optimizationcommitment workflow. - AKS driver: AKS cost analysis.