get-gcp-recommendation
dci get-gcp-recommendation <billingAccountId> <gcp_service> [flags]
Returns the recommendation for one product line (gcp_service) and region scope on the GCP
billing account, including analysis metrics and time-bucketed eligible spend. Use
granularity to choose the eligible-spend bucket size (defaults to day).
region: optional for compute, defaulting to global (its only scope). Required
for cloud_sql — omitting it returns 400 with code validation_failed, as does a
malformed region or one incompatible with gcp_service (cloud_sql never uses global).
A well-formed region the billing account has never had eligible spend in returns 404
with code not_found — the scope does not exist, same as an unknown billing account.
When the scope exists but no stored recommendation matches, the response is 200 with
recommendation omitted and estimatedEquivalentRecommendedCommitment of 0.
billingAccountId— GCP Billing Account ID (formatXXXXXX-XXXXXX-XXXXXX; the account that owns the CUDs) that scopes the request.gcp_service— PS4C product line to fetch the recommendation for. Matching is case-insensitive; the value is lowercased before validation.
Flags
| Flag | Type | Default | Example | Description |
|---|---|---|---|---|
--region | string | us_east1 | Filter by region scope, in lower_snake_case wire form (for example us_east1), or the literal global. Requires gcp_service; a request with region but no gcp_service returns 400 with code gcp_service_required. When both are omitted, all available regions for all available product lines are returned. The value is format-validated, not checked against a closed region list: compute accepts only global, cloud_sql accepts only concrete regions (never global), and a value that is malformed or incompatible with gcp_service returns 400 with code validation_failed. A well-formed, service-compatible region with no data returns 200 with an empty result. Matching is case-insensitive; the value is lowercased before validation. | |
--granularity | string | "day" | Time bucket size for eligible-spend data points on the recommendation response. If omitted, defaults to day. Coarser buckets return min/max/median usage; hour returns per-hour totals. One of: "hour", "day", "week", "month". |
Every command also accepts the CLI-wide flags for output shaping — see Output formats and Table output options.
Output
Recommendation detail with eligible-spend usage series.
By default dci renders the result as a table. Use --output json to get the full structure described below — see Output formats.
| Field | Type | Description |
|---|---|---|
estimatedEquivalentRecommendedCommitment | number (double) | Shelf-price hourly equivalent ($/h) of the recommended commitment, derived from the median hourly eligible usage over the trailing window multiplied by estimatedAverageCoverage. Use this to compare the recommendation line to eligible usage on charts. |
recommendation | object | Recommended commitment metrics for the requested (service, region) scope. |
recommendation.policy | string | Coverage target policy configured for this product line and region scope (built-in or customer-defined). |
recommendation.region | string | Region scope for this recommendation, in lower_snake_case wire form (for example us_east1). global for compute; a concrete region for cloud_sql. |
recommendation.service | string | PS4C product line (gcp_service) this recommendation belongs to. One of: "compute", "cloud_sql". |
recommendation.currentCommitment | number (double) | Active hourly commitment ($/h) currently applied to this billing account and product line, including commitments already purchased. |
recommendation.recommendedCommitment | number (double) | Recommended total hourly commitment ($/h) based on usage patterns and your commitment policy. Designed to increase savings while managing underutilization risk. |
recommendation.potentialAdditionalSavings | number (double) | Estimated additional monthly savings ($/month) from applying the recommended commitment relative to currentCommitment. |
recommendation.estimatedAverageCoverage | number (double) | Estimated average coverage of eligible spend if the recommended commitment were in place, as a fraction from 0 to 1 (for example, 0.5517 is 55.17%). Same scale as esr and the inventory utilization and coverage fields. |
eligibleUsage | array of object | Eligible spend over time at the requested granularity. Empty when no eligible usage exists in the trailing window. |
eligibleUsage[].usageTime | string (date-time) | Start of the time bucket for this data point (UTC). |
eligibleUsage[].totalUsage | number (double) | Total eligible usage in the bucket when granularity is hour. Prefer min/max/median for coarser granularities. |
eligibleUsage[].minUsage | number (double) | Minimum eligible usage ($/h) observed in the bucket (day/week/month views). |
eligibleUsage[].maxUsage | number (double) | Maximum eligible usage ($/h) observed in the bucket (day/week/month views). |
eligibleUsage[].medianUsage | number (double) | Median eligible usage ($/h) observed in the bucket (day/week/month views). |
Raw JSON schema
{
"type": "object",
"description": "A single GCP recommendation paired with its eligible-spend usage series.",
"properties": {
"estimatedEquivalentRecommendedCommitment": {
"type": "number",
"format": "double",
"description": "Shelf-price hourly equivalent ($/h) of the recommended commitment, derived from the median hourly eligible usage over the trailing window multiplied by `estimatedAverageCoverage`. Use this to compare the recommendation line to eligible usage on charts."
},
"recommendation": {
"allOf": [
{
"type": "object",
"description": "A CUD purchase recommendation for a (service, region) scope.",
"properties": {
"policy": {
"allOf": [
{
"type": "string",
"description": "ID of a commitment policy: either one of the built-in policies — `conservative` (lower\ncoverage target, ~65%), `balanced` (moderate, ~80%), `max_savings` (aggressive, ~90%) — or the\nID of a policy the customer defined in the DoiT Console. One catalog is shared by AWS and GCP,\nand the same policy may be assigned to any AWS organization or GCP billing account product\nline. Custom policies make this an open list, so it is not an enum; treat the value as an\nopaque identifier and use the commitment-policies endpoint to resolve it.",
"example": "balanced"
}
],
"description": "Coverage target policy configured for this product line and region scope (built-in or customer-defined)."
},
"region": {
"allOf": [
{
"type": "string",
"pattern": "^(global|[a-z]+(_[a-z0-9]+)+)$",
"description": "GCP region scope in the DCI `lower_snake_case` wire form (for example `us_east1`), or the\nliteral `global` for cross-region scopes. This is not the raw provider spelling (`us-east1`);\nthe same pattern applies to the `region` query parameter. Regions are discovery-driven, so the\nlist is open rather than an enum.",
"example": "us_east1"
}
],
"description": "Region scope for this recommendation, in `lower_snake_case` wire form (for example `us_east1`). `global` for `compute`; a concrete region for `cloud_sql`."
},
"service": {
"type": "string",
"enum": [
"compute",
"cloud_sql"
],
"description": "PS4C product line (`gcp_service`) this recommendation belongs to."
},
"currentCommitment": {
"type": "number",
"format": "double",
"description": "Active hourly commitment ($/h) currently applied to this billing account and product line, including commitments already purchased."
},
"recommendedCommitment": {
"type": "number",
"format": "double",
"description": "Recommended total hourly commitment ($/h) based on usage patterns and your commitment policy. Designed to increase savings while managing underutilization risk."
},
"potentialAdditionalSavings": {
"type": "number",
"format": "double",
"description": "Estimated additional monthly savings ($/month) from applying the recommended commitment relative to `currentCommitment`."
},
"estimatedAverageCoverage": {
"type": "number",
"format": "double",
"minimum": 0,
"maximum": 1,
"description": "Estimated average coverage of eligible spend if the recommended commitment were in place, as a fraction from 0 to 1 (for example, `0.5517` is 55.17%). Same scale as `esr` and the inventory utilization and coverage fields."
}
}
}
],
"description": "Recommended commitment metrics for the requested (service, region) scope."
},
"eligibleUsage": {
"type": "array",
"description": "Eligible spend over time at the requested `granularity`. Empty when no eligible usage exists in the trailing window.",
"items": {
"type": "object",
"description": "One time-bucketed eligible-spend usage point for the recommendation chart. Units are shelf-price hourly dollars ($/h) unless noted by the client visualization.",
"properties": {
"usageTime": {
"type": "string",
"format": "date-time",
"description": "Start of the time bucket for this data point (UTC).",
"nullable": true
},
"totalUsage": {
"type": "number",
"format": "double",
"description": "Total eligible usage in the bucket when granularity is `hour`. Prefer min/max/median for coarser granularities."
},
"minUsage": {
"type": "number",
"format": "double",
"description": "Minimum eligible usage ($/h) observed in the bucket (day/week/month views)."
},
"maxUsage": {
"type": "number",
"format": "double",
"description": "Maximum eligible usage ($/h) observed in the bucket (day/week/month views)."
},
"medianUsage": {
"type": "number",
"format": "double",
"description": "Median eligible usage ($/h) observed in the bucket (day/week/month views)."
}
}
}
}
}
}
Errors
On failure, dci prints a single error message — with a hint when one is available — and exits with a typed code your scripts can branch on. See Errors and exit codes for the full contract.
HTTP status to exit code mapping
| HTTP status | Exit code | Error code | Meaning |
|---|---|---|---|
| 400 | 30 | VALIDATION_ERROR | The arguments or request body were rejected. Review the command's flags and payload. |
| 401 | 10 | AUTHENTICATION_FAILED | Not signed in, or the API token is invalid. Run dci login or check DCI_API_KEY. |
| 403 | 11 | PERMISSION_DENIED | The DoiT user or the active customer context does not have access. |
| 404 | 20 | RESOURCE_NOT_FOUND | The requested resource does not exist. Check the identifier argument. |
| 500, 503 | 40 | API_SERVER_ERROR | The API failed to process the request. Retryable; contact DoiT support if it persists. |
Related
- get-gcp-billing-account — Get a GCP billing account
- list-gcp-billing-accounts — List GCP billing accounts
- list-gcp-billing-accounts-settings — List billing account engine settings
- list-gcp-planned-purchases — List GCP planned purchases
- list-gcp-recommendations — List GCP recommendations
- list-gcp-resource-cuds — List GCP resource-based Committed Use Discounts
- list-gcp-spend-cuds — List GCP spend-based Committed Use Discounts
- API reference: GET /ps4commitments/v1/gcp/billing-accounts/{billingAccountId}/recommendations/{gcp_service}
Aliases: getgcprecommendation