gcp-waf-cost-optimization
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "gcp-waf-cost-optimization":https://skillpi.com/zh/skills/deepskill-a8531f67286f65e47aff8cffca47cfa2989d4bd54dad7b6269d3f93e06504e5b。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
GCP 成本优化(WAF)专家:应用 Google Cloud 架构良好框架中成本优化支柱,对工作负载进行评估并推荐 FinOps 实践。包括账单导出与月度账单分析、预算设置、通过 Active Assist 进行资源合理调整、使用抢占式虚拟机(Spot VMs)、承诺使用折扣、存储生命周期策略以及采用无服务器架构,适用于云成本审查与架构成本决策。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: gcp-waf-cost-optimization
description: |
Apply the Google Cloud Well-Architected Framework's Cost Optimization pillar
to evaluate workloads and recommend FinOps practices — billing exports,
budgets, rightsizing via Active Assist, Spot VMs, Committed Use Discounts,
storage lifecycle policies, and serverless adoption. Use for cloud cost
reviews, monthly billing analysis, and architecture cost decisions.
license: Apache-2.0
compatibility: 'gcloud-cli, BigQuery (billing export), Cloud Billing'
metadata:
author: google-cloud
version: 1.0.0
category: devops
tags:
- gcp
- finops
- cost-optimization
- well-architected
- billingGCP Well-Architected Framework — Cost Optimization
Overview
Cloud is OpEx, not CapEx — getting cost right requires visibility (where is money going?), accountability (who owns each line item?), and continuous tuning (is each resource still earning its cost?). This skill applies the Google Cloud Well-Architected Framework's Cost Optimization pillar to evaluate a workload and recommend FinOps controls.
Instructions
Core Principles
| Principle | What it means in practice |
|---|---|
| Align spending with business value | Every dollar should map to a product/team/feature; reject infra that doesn't tie back to a business metric |
| Foster cost awareness | Make spend visible to engineers via dashboards, not just to finance |
| Optimize resource usage | Rightsize, use cheap-when-fault-tolerant compute (Spot), commit when stable (CUDs) |
| Optimize continuously | Cost reviews are recurring; act on Recommender insights monthly |
Visibility Layer (Foundation)
# Enable BigQuery billing export — required for granular analysis
gcloud beta billing accounts list # find your billing account ID
# Then in Console: Billing → Export → BigQuery export → enable "Detailed usage cost data"
-- Top 20 services by cost, last 30 days
SELECT
service.description AS service,
SUM(cost) AS cost_usd,
SUM(IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) c), 0)) AS credits_usd,
SUM(cost) + SUM(IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) c), 0)) AS net_usd
FROM `my-project.billing_export.gcp_billing_export_resource_v1_*`
WHERE _PARTITIONTIME >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
GROUP BY service
ORDER BY net_usd DESC
LIMIT 20;
-- Cost by label (env, team, app) — requires consistent labeling
SELECT
(SELECT value FROM UNNEST(labels) WHERE key = 'team') AS team,
(SELECT value FROM UNNEST(labels) WHERE key = 'env') AS env,
service.description AS service,
SUM(cost) AS cost_usd
FROM `my-project.billing_export.gcp_billing_export_resource_v1_*`
WHERE _PARTITIONTIME >= TIMESTAMP_SUB(CURRENT_TIMESTAMP(), INTERVAL 30 DAY)
GROUP BY team, env, service
ORDER BY cost_usd DESC;
Budgets and Alerts
# Per-project budget with alerts at 50%, 90%, 100% of forecasted spend
gcloud billing budgets create \
--billing-account=BILLING_ACCOUNT_ID \
--display-name="prod-monthly-budget" \
--budget-amount=10000USD \
--threshold-rule=percent=0.5,basis=current-spend \
--threshold-rule=percent=0.9,basis=current-spend \
--threshold-rule=percent=1.0,basis=forecasted-spend \
--filter-projects=projects/my-project \
--notifications-rule-pubsub-topic=projects/my-project/topics/billing-alerts
Pipe the Pub/Sub topic to a Cloud Function that auto-disables non-critical resources at 95% of budget for dev/test projects.
Rightsizing via Active Assist
# List rightsizing recommendations across the project
gcloud recommender recommendations list \
--project=my-project \
--location=us-central1-a \
--recommender=google.compute.instance.MachineTypeRecommender \
--format='table(content.overview.currentMachineType, content.overview.recommendedMachineType, primaryImpact.costProjection.cost.units)'
# Idle VMs (consider stopping or deleting)
gcloud recommender recommendations list \
--project=my-project \
--location=us-central1-a \
--recommender=google.compute.instance.IdleResourceRecommender
# Idle persistent disks
gcloud recommender recommendations list \
--project=my-project \
--location=us-central1-a \
--recommender=google.compute.disk.IdleResourceRecommender
Cheaper Compute
# Spot VMs — up to 91% cheaper, can be preempted with 30s notice
gcloud compute instances create batch-worker \
--zone=us-central1-a \
--machine-type=n2-standard-4 \
--provisioning-model=SPOT \
--instance-termination-action=DELETE
# Committed Use Discount — 1 or 3 year commit, ~57% off for stable workloads
gcloud compute commitments create prod-commit-3y \
--region=us-central1 \
--resources=vcpu=64,memory=256 \
--plan=THIRTY_SIX_MONTH \
--type=GENERAL_PURPOSE
For variable workloads, use Cloud Run / Cloud Run functions / GKE Autopilot — pay for actual request seconds, not provisioned capacity. Migrating a low-traffic API from a Compute Engine VM to Cloud Run typically cuts cost 70%+.
Storage Lifecycle Policies
# Move objects to cheaper tiers automatically
cat > lifecycle.json <<EOF
{
"lifecycle": {
"rule": [
{ "action": { "type": "SetStorageClass", "storageClass": "NEARLINE" },
"condition": { "age": 30 } },
{ "action": { "type": "SetStorageClass", "storageClass": "COLDLINE" },
"condition": { "age": 90 } },
{ "action": { "type": "SetStorageClass", "storageClass": "ARCHIVE" },
"condition": { "age": 365 } },
{ "action": { "type": "Delete" },
"condition": { "age": 2555 } }
]
}
}
EOF
gcloud storage buckets update gs://my-archive-bucket --lifecycle-file=lifecycle.json
Storage class pricing (US, per GB-month, approximate): Standard $0.020, Nearline $0.010, Coldline $0.004, Archive $0.0012. Lifecycle rules pay for themselves within weeks on cold data.
Workload Assessment Questions
When evaluating a workload, work through:
- Is BigQuery billing export enabled and used in monthly reviews?
- Are 100% of resources labeled with
env,team,app? - Are budgets + alerts configured per project / business unit?
- Are Active Assist rightsizing recommendations reviewed monthly?
- Is CUD coverage reviewed against actual stable consumption?
- Are idle disks, IPs, and VMs swept monthly?
- Are new workloads serverless-by-default unless there's a hard reason not to be?
- Do object storage buckets have lifecycle policies?
- Is dev/test on Spot, off-hours shutdown, or cheaper tiers than prod?
- Are there organization policies preventing expensive defaults (regions, machine types)?
Validation Checklist
- [ ] Cost attribution — 100% of resources carry
env,team,applabels - [ ] Granular visibility — BigQuery billing export enabled, queried in monthly reviews
- [ ] Budgets and alerts — every project / BU has a budget with 50%/90%/100% alerts
- [ ] Rightsizing — Active Assist recommendations reviewed and acted on monthly
- [ ] Commitments — CUD coverage reviewed monthly against stable consumption
- [ ] Idle resource sweeps — disks, IPs, VMs cleaned up monthly
- [ ] Managed services first — serverless preferred for new workloads
- [ ] Storage tiering — lifecycle policies on all archival buckets
- [ ] Org policies — region / machine type / external IP restrictions enforced
- [ ] Dev/test cost — non-prod runs on Spot, scales to zero, or shuts down off-hours
Examples
Example 1 — Monthly cost review for a startup
User shares last month's GCP bill ($15k, up from $9k). Pull billing-export data into BigQuery, group by service and label, identify the spike (a forgotten n2-standard-32 in dev with no auto-shutdown). Run Active Assist rightsizing across the project, surface 6 idle disks and 12 oversized VMs. Estimated savings: $4.2k/month. Recommend a CUD for the stable Compute Engine baseline (+$1.8k/month savings) and lifecycle policies on three archival buckets (+$200/month).
Example 2 — Architectural cost review of a new service
Team is designing a new background job processor. Default proposal is 6 always-on n2-standard-8 VMs ($1.4k/month). Recommend Cloud Run Jobs with --task-count matching peak burst — pay only for actual job seconds (~$200/month at expected volume). For the message queue, Pub/Sub instead of self-hosted RabbitMQ on GCE. For object storage, Standard tier with lifecycle to Coldline at 90 days.
Guidelines
- Labels first — without
env/team/applabels, every other recommendation is approximate - BigQuery billing export beats Console reports for any non-trivial analysis
- Budgets with Pub/Sub alerts — wire to a function that can auto-disable resources for dev/test
- Recommender insights are passive — schedule a monthly sweep, don't expect them to act themselves
- Spot VMs are the right default for any fault-tolerant workload (CI, batch, inference, dev/test)
- CUDs require >12 months of usage history to size correctly — never commit before that
- Migrate static-VM workloads to Cloud Run / Cloud Run Jobs / GKE Autopilot whenever possible
- Storage lifecycle policies pay for themselves in weeks; there's no reason not to set them
- For multi-team accounts, use Folders + per-folder budgets and aggregated billing rollups
- Set Org Policies to restrict regions and machine types — prevents accidentally provisioning the world's most expensive VM in Sydney
当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供完整的 GCP 成本优化方案,涵盖 FinOps 核心实践
- 适用于云成本审查、月度账单分析和架构决策,受众广泛
- 结合 Well-Architected Framework,具备权威性和实用性
亮点
- description 清晰描述适用场景与核心功能
- 触发词完整,边界清晰,覆盖多种变体
亮点
- 文档结构清晰,包含完整执行流程与端到端示例
- frontmatter 完整,单文件未超限,排版规范
亮点
- 命令基于标准 gcloud CLI 和 BigQuery SQL,参数正确
- 覆盖主要异常处理建议,提供完整验证清单
- 不可逆操作有明确业务逻辑建议,可靠性高
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
云资源与可能的费用
先预览变更,核对账号、区域、资源权限与费用;创建、部署或删除前单独确认。
主文档提及 · 第 79, 123, 132 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。