gcp-cost-optimizer
GCP Cost Optimizer
Quick Start
Analyze GCP costs and implement optimization strategies to reduce spending.
Instructions
Step 1: Analyze current costs
# View billing data
gcloud billing accounts list
# Export billing data to BigQuery
gcloud billing accounts projects link PROJECT_ID \
--billing-account=BILLING_ACCOUNT_ID
# Query costs
bq query --use_legacy_sql=false \
'SELECT service.description, SUM(cost) as total_cost
FROM `project.dataset.gcp_billing_export`
WHERE DATE(_PARTITIONTIME) >= DATE_SUB(CURRENT_DATE(), INTERVAL 30 DAY)
GROUP BY service.description
ORDER BY total_cost DESC'
Step 2: Identify optimization opportunities
Committed Use Discounts:
- 1-year or 3-year commitments
- Up to 57% savings for Compute Engine
- Up to 70% savings for Cloud SQL
Sustained Use Discounts:
- Automatic discounts for running instances
- Up to 30% for instances running >25% of month
Preemptible VMs:
- Up to 80% savings
- Suitable for fault-tolerant workloads
Rightsizing:
- Use Recommender API for suggestions
- Downsize overprovisioned instances
- Adjust machine types
Step 3: Implement cost-saving measures
# Get rightsizing recommendations
gcloud recommender recommendations list \
--project=PROJECT_ID \
--location=us-central1 \
--recommender=google.compute.instance.MachineTypeRecommender
# Apply recommendation
gcloud recommender recommendations mark-claimed \
RECOMMENDATION_ID \
--project=PROJECT_ID \
--location=us-central1 \
--recommender=google.compute.instance.MachineTypeRecommender
Best Practices
- Enable billing export to BigQuery
- Set up budget alerts
- Use labels for cost allocation
- Review Recommender suggestions monthly
- Implement committed use discounts for stable workloads
- Use preemptible VMs for batch processing
- Clean up unused resources regularly
- Optimize storage classes
More from armanzeroeight/fastagent-plugins
kubernetes-best-practices
Provides production-ready Kubernetes manifest guidance including resource management, security, high availability, and configuration best practices. This skill should be used when working with Kubernetes YAML files, deployments, pods, services, or when users mention k8s, container orchestration, or cloud-native applications.
11schema-designer
Design database schemas with proper normalization, relationships, constraints, and indexes. Use when creating database tables, modeling data relationships, or designing database structure.
11api-documentation-generator
Generate OpenAPI/Swagger specifications and API documentation from code or design. Use when creating API docs, generating OpenAPI specs, or documenting REST APIs.
9goroutine-patterns
Implement Go concurrency patterns using goroutines, channels, and synchronization primitives. Use when building concurrent systems, implementing parallelism, or managing goroutine lifecycles. Trigger words include "goroutine", "channel", "concurrent", "parallel", "sync", "context".
9inventory-manager
Organizes Ansible inventory files, manages host groups, and configures dynamic inventory. Use when organizing Ansible inventory, managing host groups, or setting up dynamic inventory sources.
9complexity-analyzer
Analyzes cyclomatic and cognitive complexity, identifies overly complex functions. Use when assessing code complexity or identifying functions that need simplification.
9