Get total cost


Obtains the total cost incurred for the resource usage for a specified interval. The interval can be monthly, quarterly, half-yearly, or yearly.

Total cost

You can retrieve the overall cost of resource usage for all the cloud providers for a specified interval.

Request details

HTTP method: POST

Request URL: https://<host_name>/cloudcost/api/v1/core/resources/cost/fetch_total

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

Headers:

Parameter

Value

Required

Description

Authorization

'Bearer {jwt token}'

Yes

Authorization token.

Content-Type

application/json

Yes

Accepted content type.

account_aggregations_ready

true

No

Required for monthly duration.

Request body properties:

Property

Type

Required

Description

start

Long

Yes

The date from when you want to view the resource cost.

end

Long

Yes

The date up to when you want to view the resource cost.

Sample request

{
"start": 1617235200000,
"end": 1625097599999
}

Sample response

200  OK
{
"total_cost": 898444.7,
"original_cost": 898444.7
}

Total cost includes the discount, whereas the original cost is without any discount.

Cost per cloud provider, account, service, or resource

You can retrieve the resource usage cost for a specified interval according to a cloud provider, account, cloud-native service, or resource.

Request details

HTTP method: POST

Request URL: https://<host_name>/cloudcost/api/v1/core/resources/cost/fetch_total

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

Headers

Parameter

Value

Required

Description

Authorization

'Bearer {jwt token}'

Yes

Authorization token.

Content-Type

application/json

Yes

Accepted content type.


Request body properties

Property

Type

Required

Description

start

Long

Yes

The date from when you want to view the resource cost.

end

Long

Yes

The date up to when you want to view the resource cost.

filter

Sting

Yes

The filter to be used to obtain the cost according to provider name, account name, resource pool, and resource. You can use multiple filters.

Sample requests

Request to filter by an account name:

{
"start": 1617235200000,
"end": 1625097599999,
"filter": "account_name = 'testproject'"
}

Request to filter by a provider name:

{
"start": 1617235200000,
"end": 1625097599999,
"filter": "provider_id = 'aws'"
}

Request to filter by a service name:

{
"start": 1617235200000,
"end": 1625097599999,
"filter": "service_name = 'Amazon Elastic Compute Cloud'"
}

Request to filter by a resource ID:

{
"start": 1617235200000,
"end": 1625097599999,
"filter": "resource_id IN ['7651748638']"
}

Request containing multiple filters:

Sample 1:

{
"start": 1622505600000,
"end": 1625097599999,
"filter": "provider_id = 'azure' AND account_name = 'production'"
}

Sample 2:

{
   "start": 1625097600000,
   "end": 1627775999999,
   "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
{
"total_cost": 20003.7,
"original_cost": 20003.7
}

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*