Subchapter 27.28
references/phases/discover/discover-billing.mdMarkdown7 KBView on GitHub
Self-contained billing discovery sub-file. Scans for billing CSV/JSON files, parses billing data, builds service usage profiles, flags AI signals, and generates
billing-profile.json. If no billing files are found, exits cleanly with no output.
Execute ALL steps in order. Do not skip or optimize.
Scan the target directory for billing data:
**/*billing*.csv — GCP billing export CSV**/*billing*.json — BigQuery billing export JSON**/*cost*.csv, **/*cost*.json — Cost report exports**/*usage*.csv, **/*usage*.json — Usage report exportsExclude .migration/** — migration run artifacts (e.g. openai-usage-profile.json, openai-capture/) are never billing input.
Exit gate: If NO billing files are found, exit cleanly. Return no output artifacts. Other sub-discovery files may still produce artifacts.
Supported formats:
Extract from each line item:
service_description — GCP service namesku_description — Specific SKU/resourcecost — Cost amountusage_amount — Usage quantityusage_unit — Usage unit (e.g., hours, bytes, requests)Group by service and calculate monthly totals.
Scan billing line items for GCP Committed Use Discount (CUD) artifacts and other billing-level discounts. These are not workload costs — they are financial instruments that must be separated from actual resource usage.
| Pattern | How to identify | Type |
|---|---|---|
| Resource-based CUD fee | SKU contains “Commitment v1:” (e.g., “Commitment v1: E2 Cpu in Americas for 1 Year”) | resource_based |
| Dollar-based CUD fee | SKU contains “Commitment - dollar based” (e.g., “Commitment - dollar based v1: GCE for 1 year”) | dollar_based |
| CUD credit (offset) | Column committedUsageDiscount or committedUsageDiscountDollarBase has non-zero value | credit |
| Sustained usage discount | Column sustainedUsageDiscount has non-zero value | credit |
| Subscription benefit | Column subscriptionBenefit has non-zero value | credit |
| Free tier credit | Column freeTier has non-zero value | credit |
Additional signals:
resourceGlobalName contains project_commitments → commitment fee rowresourceName starts with commitment- → commitment fee rowFor each detected commitment fee row, extract:
region fieldcostAtListUSD for all rows in that commitmentFor discount credits, sum per type across all services:
committedUsageDiscount (negative values = credits applied)sustainedUsageDiscountfreeTierIf any CUD-related columns or rows are detected:
costAtListUSD (list price) as the baseline for all service costs in Step 2total_at_list (sum of all costAtListUSD)total_net_of_discounts (list price + all discount credits)effective_discount_percent: (total_at_list - total_net_of_discounts) / total_at_list × 100If no CUD columns are present in the export (older export format), use the available cost column as-is and set cost_basis.uses_list_price to false.
From the parsed billing data:
costAtListUSD) when available — exclude commitment fee rows from service totalsScan billing line items for AI-relevant patterns. For each match, record the pattern, line item details, and confidence score.
| Pattern | What to look for | Confidence |
|---|---|---|
| 3.1 Vertex AI billing | Description contains “Vertex AI”, “AI Platform”; monthly cost > $10 | 98% |
| 3.2 BigQuery ML billing | “BigQuery ML” line items + high BigQuery analysis costs (>$500/month) | 80% |
| 3.3 Generative AI API | “Generative AI API”, “Gemini API”, foundation model token charges | 95% |
| 3.4 Specialized AI services | “Document AI”, “Vision AI”, “Speech-to-Text”, “Natural Language API”, “Cloud Translation”, “Dialogflow” | 85% |
Write $MIGRATION_DIR/billing-profile.json with the following structure:
{
"metadata": {
"report_date": "2026-02-24",
"project_directory": "/path/to/project",
"billing_source": "gcp-billing-export.csv",
"billing_period": "2026-01"
},
"summary": {
"total_monthly_spend": 2450.00,
"service_count": 8,
"currency": "USD"
},
"services": [
{
"gcp_service": "Cloud Run",
"gcp_service_type": "google_cloud_run_service",
"monthly_cost": 450.00,
"percentage_of_total": 0.18,
"top_skus": [
{
"sku_description": "Cloud Run - CPU Allocation Time",
"monthly_cost": 300.00
},
{
"sku_description": "Cloud Run - Memory Allocation Time",
"monthly_cost": 150.00
}
],
"ai_signals": []
}
],
"commitments": {
"has_active_cuds": false,
"total_monthly_commitment_fees": 0.00,
"total_monthly_cud_credits": 0.00,
"effective_discount_percent": 0.0,
"details": []
},
"cost_basis": {
"uses_list_price": true,
"total_at_list": 2450.00,
"total_net_of_discounts": 2450.00,
"discount_breakdown": {
"committed_usage_discount": 0.00,
"sustained_usage_discount": 0.00,
"free_tier": 0.00
}
},
"ai_signals": {
"detected": false,
"confidence": 0,
"services": []
}
}Load references/shared/schema-discover-billing.md and validate the output against the billing-profile.json schema.
After generating the output file, the parent discover.md handles the phase status update — do not update .phase-status.json here.
This phase covers Discover & Analysis ONLY.
FORBIDDEN — Do NOT include ANY of:
Your ONLY job: Inventory what exists in GCP. Nothing else.