Get cost items


Obtains the cost items for a specified interval, such as monthly, yearly, half-yearly, and quarterly.

Request details

HTTP method: POST

Request URLhttps://<host_name>/cloudcost/api/v1/core/resources/cost/aggregation

Examplehttps://portal.us1.onbmc.com/cloudcost/api/v1/core/resources/cost/aggregation

HeaderSee HTTP request and response headers for header information, such as required authorization token.

Request body properties

Property

Type

Required

Description

size

Integer

No

The number of cost items that you want to fetch. The default is 20. Any integer greater than 0 is accepted.

from

Integer

No

The range of cost items to be fetched. The default is 0. Any integer that is 0 or greater is accepted. For example, if the available cost items are 100 and you specify size as 10 and from as 1, the response will contain the first 10 cost items.

start

Long

Yes

The date (in msec epoch time (GMT)) from when you want to view the cost items.

end

Long

Yes

The date (in msec epoch time (GMT)) up to when you want to view the cost items.

resource_filter

Sting

No

The resource pool IDs.

Sample requests

Request to obtain cost items per provider

{
"size": 1, //(upto 5000)
"from": 0,
"start": "1622505600000",
"end": "1625097599999",
"feature": "enableLocalResourceData",
"resource_filter": "provider_id = 'aws'"
}

Request to obtain cost items per account name

{
"size": 5000,
"from": 0,
"start": "1622505600000",
"end": "1625097599999",
"feature": "enableLocalResourceData",
"resource_filter": "account_name = 'mvpproject'"
}

Request to obtain cost items per service name

{
"size": 5000,
"from": 0,
"start": "1622505600000",
"end": "1625097599999",
"feature": "enableLocalResourceData",
"resource_filter": "service_name = 'Amazon API Gateway'"
}

Request containing multiple filters:

Sample 1:

{
"start": 1622505600000,
"end": 1625097599999,
"resource_filter": "provider_id = 'azure' AND account_name = 'activetwp'"
}

Sample 2:

{
   "start": 1625097600000,
   "end": 1627775999999,
   "resource_filter": "account_name CONTAINS 'AWS'"
}

Similarly, you can specify filters for 'service_name' and 'region' using any of these criteria:

  • IS EMPTY
  • IS NOT EMPTY
  • CONTAINS
  • NOT CONTAINS
  • STARTS_WITH
  • ENDS_WITH

Sample response

200 OK
{
   "resource_cost": [
        {
           "cost": 37200.0,
           "account_id": "12ARDAF",
           "account_name": "test_AWS_1234",
           "provider_id": "aws",
           "provider_name": "aws",
           "resource_id": "11ARDAF:abcd",
           "name": "3 year No Upfront Compute Savings Plan",
           "service_id": "ComputeSavingsPlans",
           "region": "global",
           "tags": [],
           "bmc_tags": null,
           "properties": {
               "actual_resource_id": "",
               "usage-amount": 234,
               "instance-type": "3yrNoUpfront",
               "availability-zone": ""
            },
           "connector_id": "",
           "app_id": "",
           "sku": "ZGC49G9XS7QA34BQ",
           "type": "SavingsPlanRecurringFee",
           "license_type": null,
           "master_account_id": "12ARDAF",
           "created_at": 1612137600000,
           "service_name": "Savings Plans for AWS Compute usage",
           "category": "tax",
           "resource_pool_ids": [],
           "state": null
        }
    ]
}

Status codes and messages

HTTP code

Description

200

OK

401

Unauthorized

400

Bad request

403

Forbidden

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*