メインコンテンツへスキップ

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.

FieldTypeDescription
diagramIdstringDiagram (layer) ID this snapshot was computed for.
currencystringCurrency the cost numbers are reported in (e.g. USD).
timeRangeobjectResolved cost window for the snapshot.
timeRange.startDatestring (date)Inclusive start of the cost window (ISO date).
timeRange.endDatestring (date)Inclusive end of the cost window (ISO date).
timeRange.intervalstringBucket interval used for the trend series. One of: "day", "week", "month".
totalnumberTotal cost across the entire diagram for the snapshot window.
trendingPctnumberPeriod-over-period change as a fraction (e.g. 0.142 = +14.2%). null when no prior period of equal length is available for comparison.
topResourcesarray of objectTop resources by cost, capped at 5.
topResources[].idstringResource id (cloud-native id when available; otherwise the diagram component id).
topResources[].namestringHuman-readable resource name.
topResources[].typestringResource type label (e.g. ec2, rds).
topResources[].amountnumberCost amount for this resource within the snapshot window.
byServicearray of objectTop services by cost, capped at 5.
byService[].servicestringCloud service label (e.g. EC2).
byService[].amountnumberCost amount for this service within the snapshot window.
trendarray of objectMost recent trend buckets at the requested interval, capped at 12.
trend[].bucketStartstringInclusive start of this bucket. ISO date for day and month; week label for week.
trend[].amountnumberTotal 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 statusExit codeError codeMeaning
40030VALIDATION_ERRORThe arguments or request body were rejected. Review the command's flags and payload.
40110AUTHENTICATION_FAILEDNot signed in, or the API token is invalid. Run dci login or check DCI_API_KEY.
40311PERMISSION_DENIEDThe DoiT user or the active customer context does not have access.

Aliases: getclouddiagramcostsnapshot