Robertjam954/multimodal_rag_application / .claude/skills/azure-cost
azure-cost
VerifiedAzure cost management: query costs, forecast spending, optimize to reduce waste. WHEN: "Azure costs", "Azure bill", "cost breakdown", "how much am I spending", "forecast spending", "optimize costs", "reduce spending", "orphaned resources", "rightsize VMs", "cost spike", "reduce storage costs", "AKS cost". DO NOT USE FOR: deploying resources, provisioning, diagnostics, or security audits.
cost-optimization/azure-aks-anomalies.md
View on GitHub# AKS Cost Anomaly Investigation
Investigate user-reported cost or utilization spikes by correlating Azure Monitor metrics, scaling events, and Cost Management data.
## Step 1 - Confirm Timeframe
Ask the user: "When did you notice the spike? (e.g., 'last Tuesday', 'between 2 AM and 4 AM yesterday')"
## Step 2 - Pull Cost Data
```bash
az rest --method post \
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.CostManagement/query?api-version=2023-11-01" \
--headers "ClientType=GitHubCopilotForAzure" \
--body '{
"type": "ActualCost",
"timeframe": "Custom",
"timePeriod": { "from": "<start-date>", "to": "<end-date>" },
"dataset": {
"granularity": "Daily",
"aggregation": { "totalCost": { "name": "Cost", "function": "Sum" } },
"grouping": [{ "type": "Dimension", "name": "ResourceId" }]
}
}'
```
## Step 3 - Pull Node Count and Scaling Events
```bash
# First, verify available metrics on your AKS resource
az monitor metrics list-definitions \
--resource "<aks-resource-id>" \
--output table
# Node count over the anomaly window (use metric name from list-definitions output)
az monitor metrics list \
--resource "<aks-resource-id>" \
--metrics "<verified-node-count-metric>" \
--interval PT5M --aggregation Count \
--start-time "<start-date>" --end-time "<end-date>"
# HPA scaling events
kubectl get events --all-namespaces \
--field-selector reason=SuccessfulRescale \
--sort-by='.lastTimestamp'
```
## Step 4 - Top Consumers
```bash
kubectl top nodes
kubectl top pods --all-namespaces --sort-by=cpu
```
## Common Causes
| Symptom | Likely Cause | Action |
|---------|-------------|--------|
| Node count surged off-peak | HPA/VPA misconfiguration | Review HPA min replicas |
| Single pod consuming all CPU | Memory leak or runaway process | Check logs, add resource limits |
| Cost spike on specific day | Batch job ran unexpectedly | Review CronJob schedule |
| Persistent high node count | CAS scale-down blocked | Check PodDisruptionBudgets, system pods |
| Sudden namespace cost jump | New deployment with no resource limits | Add requests/limits |
## Set Up Budget Alert
```bash
az consumption budget create \
--budget-name "aks-monthly-budget" \
--amount <budget-amount> \
--time-grain Monthly \
--start-date "<YYYY-MM-01>" \
--end-date "<YYYY-MM-01>" \
--resource-group "<resource-group>" \
--threshold 80 \
--contact-emails "<contact-email>"
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |