83 lines
2.2 KiB
Markdown
83 lines
2.2 KiB
Markdown
# Cost Management Rules
|
|
**OSVauco-NMTMD-GCOS | GCP Agent Master Repo**
|
|
|
|
## 1. Budget Alerts
|
|
|
|
```bash
|
|
gcloud billing budgets create \
|
|
--billing-account="${BILLING_ACCOUNT_ID}" \
|
|
--display-name="Agent Platform Budget" \
|
|
--budget-amount=500USD \
|
|
--threshold-rule=percent=0.5,basis=CURRENT_SPEND \
|
|
--threshold-rule=percent=0.8,basis=CURRENT_SPEND \
|
|
--threshold-rule=percent=1.0,basis=CURRENT_SPEND
|
|
```
|
|
|
|
## 2. Resource Labeling
|
|
|
|
All GCP resources MUST carry:
|
|
|
|
| Label Key | Example | Purpose |
|
|
|-----------|---------|--------|
|
|
| env | prod/dev/staging | Environment |
|
|
| team | osvaucoe | Cost attribution |
|
|
| cost-center | ai-platform | Finance |
|
|
| agent | orchestrator/rag | Per-agent tracking |
|
|
|
|
## 3. Cloud Run Cost Controls
|
|
|
|
```bash
|
|
gcloud run deploy ${SERVICE} \
|
|
--max-instances=10 \
|
|
--concurrency=80 \
|
|
--timeout=300
|
|
```
|
|
|
|
- CPU throttling on for non-latency-critical agents
|
|
- min-instances=1 only for latency-sensitive services
|
|
|
|
## 4. Vertex AI Cost Controls
|
|
|
|
- Use gemini-2.0-flash for high-volume sub-agent calls
|
|
- Context caching for repeated prompts (up to 75% savings)
|
|
- max_output_tokens=2048 for most tasks
|
|
- Monitor: aiplatform.googleapis.com/prediction/online/token_count
|
|
|
|
## 5. RAG Engine Cost Controls
|
|
|
|
- Delete stale documents from corpus
|
|
- Batch embedding for initial ingestion
|
|
- top_k=5 (not higher)
|
|
- Archive cold corpora to Cloud Storage lower tier
|
|
|
|
## 6. Memory Bank Cost Controls
|
|
|
|
- TTL: 7 days for short-lived session memories
|
|
- Firestore-backed for most use cases
|
|
- Index only user_id and session_id
|
|
|
|
## 7. Networking Cost Controls
|
|
|
|
- Private Google Access to avoid Vertex AI egress charges
|
|
- VPC routing for all agent traffic
|
|
- Cloud NAT only where unavoidable
|
|
|
|
## 8. Storage Lifecycle
|
|
|
|
```json
|
|
{
|
|
"rule": [{
|
|
"action": { "type": "Delete" },
|
|
"condition": { "age": 7 }
|
|
}]
|
|
}
|
|
```
|
|
Apply with: `gcloud storage buckets update gs://BUCKET --lifecycle-file=lifecycle.json`
|
|
|
|
## 9. End-of-Day Teardown Checklist
|
|
|
|
- [ ] Run 03-teardown.sh
|
|
- [ ] Verify no active Agent Runtimes: `gcloud ai agent-engines list --region=us-central1`
|
|
- [ ] Verify no active Vertex AI endpoints: `gcloud ai endpoints list --region=us-central1`
|
|
- [ ] Check billing dashboard for anomalies
|