Billing Usage API, gRPC: ConsumptionCoreService.GetLabelKeyUsageReport
Returns aggregated usage report by label keys and values
under the specified billing account.
This method provides detailed usage and cost information grouped by label key-value pairs
within the specified billing account. Labels are user-defined metadata tags attached to resources
(such as VMs, disks, etc.) in the form of key-value pairs (e.g., "env:prod", "region:us-west").
The data can be filtered by various entity types and aggregated at different time granularities.
Implementation details:
- Results are organized by label key-value pairs, with usage, costs, and credits detailed for each
- If labels filter is specified, only data for matching labels is included
- Other filters (cloud_ids, folder_ids, service_ids, sku_ids, resource_ids) are always applied if present
- Resources can have multiple labels attached (e.g., a VM might have "env:prod", "team:finance", "region:us")
- If a resource has multiple labels at the same point in time, the usage and cost metrics are reported for each label separately.
In other words, the same resource's cost is duplicated across its labels rather than split. For example,
if a VM costs 90 units and has 3 labels, the report will show 90 units for each label, not 30 units per label. - This allows for custom business dimensions analysis based on resource tagging
- Usage data is aggregated for all resources that share the same label
- Particularly useful for cost allocation and chargeback across business units, environments, or projects
Error handling:
- Returns INVALID_ARGUMENT if the request parameters fail validation
- Returns UNAUTHENTICATED if the user is not authenticated or the billing account does not exist
- Returns PERMISSION_DENIED if the user lacks required permissions
- Returns INTERNAL for internal server errors
gRPC request
rpc GetLabelKeyUsageReport (UsageReportRequest) returns (LabelKeyUsageReportResponse)
UsageReportRequest
{
"billing_account_id": "string",
"start_date": "google.protobuf.Timestamp",
"end_date": "google.protobuf.Timestamp",
"cloud_ids": [
"string"
],
"folder_ids": [
"string"
],
"service_ids": [
"string"
],
"sku_ids": [
"string"
],
"labels": "map<string, LabelList>",
"resource_ids": [
"string"
],
"aggregation_period": "TimeGrouping"
}
Request for retrieving usage report data.
This message defines the parameters for requesting usage reports across
all ConsumptionCoreService methods. It supports filtering by various
entity types and specifying the time range and aggregation period.
|
Field |
Description |
|
billing_account_id |
string Required field. Required. Billing account identifier. |
|
start_date |
Required field. Required. Inclusive start date for metrics selection (UTC). |
|
end_date |
Required field. Required. Inclusive end date for metrics selection (UTC). |
|
cloud_ids[] |
string Optional. List of cloud IDs to filter the data. |
|
folder_ids[] |
string Optional. List of folder IDs to filter the data. |
|
service_ids[] |
string Optional. List of Service IDs to filter the data. |
|
sku_ids[] |
string Optional. List of SKU (Stock Keeping Unit) IDs to filter the data. |
|
labels |
object (map<string, LabelList>) Optional. Filter by labels: key is label key (e.g., "env", "team", "region"), Example: To filter resources that have either (env=prod OR env=test) AND (team=finance), Note: The filter logic is (value1 OR value2 OR ...) for each key, |
|
resource_ids[] |
string Optional. List of resource IDs to filter the data. |
|
aggregation_period |
enum TimeGrouping Optional. Aggregation granularity for the report, controlling how data points are grouped
This setting affects the time series data returned in the periodic field of each entity.
|
LabelList
Represents a list of label values for filtering or grouping in usage reports.
For example, to filter resources with label key "env" that have value "prod" or "test",
a LabelList with values ["prod", "test"] would be used for the key "env".
|
Field |
Description |
|
values[] |
string List of label values associated with a specific label key. |
LabelKeyUsageReportResponse
{
"currency": "Currency",
"cost": {
"value": "string"
},
"credit_details": {
"credit": {
"value": "string"
},
"monetary_grant_credit": {
"value": "string"
},
"volume_incentive_credit": {
"value": "string"
},
"cud_credit": {
"value": "string"
},
"free_credit": {
"value": "string"
}
},
"expense": {
"value": "string"
},
"entities_data": [
{
"cost": {
"value": "string"
},
"credit_details": {
"credit": {
"value": "string"
},
"monetary_grant_credit": {
"value": "string"
},
"volume_incentive_credit": {
"value": "string"
},
"cud_credit": {
"value": "string"
},
"free_credit": {
"value": "string"
}
},
"expense": {
"value": "string"
},
"label": {
"key": "string",
"value": "string"
},
"periodic": [
{
"cost": {
"value": "string"
},
"credit_details": {
"credit": {
"value": "string"
},
"monetary_grant_credit": {
"value": "string"
},
"volume_incentive_credit": {
"value": "string"
},
"cud_credit": {
"value": "string"
},
"free_credit": {
"value": "string"
}
},
"expense": {
"value": "string"
},
"timestamp": "google.protobuf.Timestamp"
}
]
}
]
}
Response for usage report requests by label-based grouping.
Contains aggregated usage, cost, and credit information organized by label key-value pairs
(e.g., "env:prod", "team:finance"), with both summary totals and detailed breakdowns for each label group.
This allows analyzing costs across custom business dimensions defined by user-attached labels.
The response includes:
- Overall totals for the entire period (cost, credits, expense)
- Entity-level totals for each label key-value pair
- Time series breakdown for each label key-value pair according to the requested aggregation period
|
Field |
Description |
|
currency |
enum Currency Currency code (e.g., "RUB", "USD") for all monetary values in the response.
|
|
cost |
Total usage cost for the selected time period. |
|
credit_details |
Total credits (monetary grants, volume incentives, committed use discounts, and free credits) applied in the selected period. |
|
expense |
Total expense (including cost and credit) for the selected time period. |
|
entities_data[] |
Detailed usage and billing data for each label entity.
|
StringDecimal
StringDecimal representation for financial values
Used to ensure precise handling of monetary values
|
Field |
Description |
|
value |
string String representation of the decimal value to avoid floating-point precision issues |
CreditDetails
Detailed breakdown of credits (discounts, incentives, grants, etc.) applied to an entity.
Credits reduce the effective cost that customers pay for cloud resources.
The 'credit' field is the total amount of credits (the sum of all credit types below).
This breakdown allows for detailed analysis of different discount types affecting billing.
|
Field |
Description |
|
credit |
Total amount of credits (sum of all credit types) applied to the entity. |
|
monetary_grant_credit |
Credits granted as a one-time monetary grant. |
|
volume_incentive_credit |
Credits given as a volume-based incentive. |
|
cud_credit |
Committed Use Discount credits. |
|
free_credit |
Credits provided as part of a 'free' program. |
LabelUsageReportEntityData
Usage and billing data for a label-based entity/grouping in the report.
This represents the second level in the response structure hierarchy (entity-level totals),
containing both summary data for the entity across the entire period and a time series breakdown.
|
Field |
Description |
|
cost |
Total cost associated with this label group. |
|
credit_details |
Total credits (discounts, grants, adjustments) applied to this label group. |
|
expense |
Total expense (including cost and credit) for this label group. |
|
label |
Metadata for the label-based grouping. |
|
periodic[] |
Time series with usage and billing details for each TimeGrouping period (e.g., daily). |
Label
Represents a key-value label pair attached to resources for custom metadata tagging.
Labels allow grouping and filtering resources by user-defined dimensions.
|
Field |
Description |
|
key |
string Label key (e.g., "region", "environment", "team", "project"). |
|
value |
string The label value (e.g., "usa", "mexico", "prod", "test", "finance", "backend") |
UsageReportPeriodicData
Represents usage and billing data for a specific aggregation period (e.g., a single day, month).
This message is part of the third level in the response structure hierarchy, providing the
time series breakdown for entities. It appears in the 'periodic' field of each entity data object,
containing financial metrics for each time interval within the requested date range.
|
Field |
Description |
|
cost |
Cost incurred during this specific period. |
|
credit_details |
Credits applied during this period. |
|
expense |
Total expense (including cost and credit) for this period. |
|
timestamp |
Timestamp indicating the beginning of the TimeGrouping period. |