get-cloud-diagram-cost-snapshot
dci get-cloud-diagram-cost-snapshot id [flags]
Returns a bounded cost snapshot for the specified diagram layer over a date window. The response composes the diagram's total spend, period-over-period change, top resources by cost (capped at 5), top services by cost (capped at 5), and a trend series (most recent 12 buckets at the requested interval).
Flags
--start-date: (string format:date)
--end-date: (string format:date)
--interval: (string enum:"day","week","month")
Output
OK - Diagram cost snapshot returned.
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 |
|---|---|---|
diagramId | string | Diagram (layer) ID this snapshot was computed for. |
currency | string | Currency the cost numbers are reported in (e.g. USD). |
timeRange | object | Resolved cost window for the snapshot. |
timeRange.startDate | string (date) | Inclusive start of the cost window (ISO date). |
timeRange.endDate | string (date) | Inclusive end of the cost window (ISO date). |
timeRange.interval | string | Bucket interval used for the trend series. One of: "day", "week", "month". |
total | number | Total cost across the entire diagram for the snapshot window. |
trendingPct | number | Period-over-period change as a fraction (e.g. 0.142 = +14.2%). null when no prior period of equal length is available for comparison. |
topResources | array of object | Top resources by cost, capped at 5. |
topResources[].id | string | Resource id (cloud-native id when available; otherwise the diagram component id). |
topResources[].name | string | Human-readable resource name. |
topResources[].type | string | Resource type label (e.g. ec2, rds). |
topResources[].amount | number | Cost amount for this resource within the snapshot window. |
byService | array of object | Top services by cost, capped at 5. |
byService[].service | string | Cloud service label (e.g. EC2). |
byService[].amount | number | Cost amount for this service within the snapshot window. |
trend | array of object | Most recent trend buckets at the requested interval, capped at 12. |
trend[].bucketStart | string | Inclusive start of this bucket. ISO date for day and month; week label for week. |
trend[].amount | number | Total cost for this bucket. |
Raw JSON schema
{
"type": "object",
"required": [
"diagramId",
"currency",
"timeRange",
"total",
"trendingPct",
"topResources",
"byService",
"trend"
],
"description": "Bounded cost snapshot for a diagram layer. Composes the diagram's total spend,\nperiod-over-period change, top resources by cost (capped at 5), top services by\ncost (capped at 5), and the most recent 12 trend buckets at the requested interval.",
"properties": {
"diagramId": {
"type": "string",
"description": "Diagram (layer) ID this snapshot was computed for."
},
"currency": {
"type": "string",
"description": "Currency the cost numbers are reported in (e.g. `USD`)."
},
"timeRange": {
"type": "object",
"required": [
"startDate",
"endDate",
"interval"
],
"description": "Resolved cost window for the snapshot.",
"properties": {
"startDate": {
"type": "string",
"format": "date",
"description": "Inclusive start of the cost window (ISO date)."
},
"endDate": {
"type": "string",
"format": "date",
"description": "Inclusive end of the cost window (ISO date)."
},
"interval": {
"type": "string",
"enum": [
"day",
"week",
"month"
],
"description": "Bucket interval used for the trend series."
}
}
},
"total": {
"type": "number",
"description": "Total cost across the entire diagram for the snapshot window."
},
"trendingPct": {
"type": "number",
"nullable": true,
"description": "Period-over-period change as a fraction (e.g. 0.142 = +14.2%). `null` when no\nprior period of equal length is available for comparison."
},
"topResources": {
"type": "array",
"description": "Top resources by cost, capped at 5.",
"maxItems": 5,
"items": {
"type": "object",
"required": [
"id",
"name",
"type",
"amount"
],
"description": "A single resource entry within the top-resources list.",
"properties": {
"id": {
"type": "string",
"description": "Resource id (cloud-native id when available; otherwise the diagram component id)."
},
"name": {
"type": "string",
"description": "Human-readable resource name."
},
"type": {
"type": "string",
"description": "Resource type label (e.g. `ec2`, `rds`)."
},
"amount": {
"type": "number",
"description": "Cost amount for this resource within the snapshot window."
}
}
}
},
"byService": {
"type": "array",
"description": "Top services by cost, capped at 5.",
"maxItems": 5,
"items": {
"type": "object",
"required": [
"service",
"amount"
],
"description": "A single service entry within the cost-by-service breakdown.",
"properties": {
"service": {
"type": "string",
"description": "Cloud service label (e.g. `EC2`)."
},
"amount": {
"type": "number",
"description": "Cost amount for this service within the snapshot window."
}
}
}
},
"trend": {
"type": "array",
"description": "Most recent trend buckets at the requested interval, capped at 12.",
"maxItems": 12,
"items": {
"type": "object",
"required": [
"bucketStart",
"amount"
],
"description": "A single bucket in the trend series.",
"properties": {
"bucketStart": {
"type": "string",
"description": "Inclusive start of this bucket. ISO date for `day` and `month`; week label for `week`."
},
"amount": {
"type": "number",
"description": "Total cost for this bucket."
}
}
}
}
}
}
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 | 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. |
Aliases: getclouddiagramcostsnapshot