Discrepancy in Cost Data Between Billing API and Elastic Cloud Console

Hi Elastic Community,

I'm trying to understand how the Billing Endpoint works in Elastic Cloud. Specifically, I'm using the /costs/<ORG_ID>/items endpoint to retrieve cost data, but the totals I'm getting from the API do not match the costs displayed in my Elastic Cloud Console.
I've ensured I'm querying the API for the same time range as displayed in the console.

I've referred to the documentation here: Elastic Cloud Billing Costs Analysis, but I'm still unclear on a few things:

  • Why might there be a discrepancy between the totals from the API and the console?
  • Are there any hidden costs that are not reflected in the billing API?
  • Are there other endpoints I need to query to get the complete or correct total cost?
  • How should I aggregate the data to match the totals shown in the Elastic Cloud Console?

Here is the response from the following curl request:

curl -XGET https://api.elastic-cloud.com/api/v1/billing/costs/ORG_ID/items -H "Authorization: ApiKey API_TOKEN

"costs": {
        "total": 2.2557, 
        "dimensions": [
            {
                "cost": 2.2269, 
                "type": "capacity"
            }, 
            {
                "cost": 0.0, 
                "type": "data_in"
            }, 
            {
                "cost": 0.0283, 
                "type": "data_internode"
            }, 
            {
                "cost": 0.0005, 
                "type": "data_out"
            }, 
            {
                "cost": 0.0, 
                "type": "storage_api"
            }, 
            {
                "cost": 0.0, 
                "type": "storage_bytes"
            }
        ]
    }, 
  "resources": [...]
 "data_transfer_and_storage": [...]

Here's the billing detail for test deployments in our console:

I've tried adjusting the query parameters to specify a time range, and am still not able to get accurate data.

We'd like to better understand what costs the specified API is returning and if we're missing any endpoints.

Thanks in advance for your help, it's greatly appreciated!

Removed #elastic-cloud

Removed #elastic-cloud

Hi @ampdd235 Welcome to the community

2 things are probably contributing to this

  • Yes most likely you are not using the same time frames
  • The Cloud console is not going to be 100% exactly the same as the Billing API for various internal reasons, but they should be very close...

Example I look at my usage from the Console from 07/01/24 to 07/28/24 those dates are inclusive

$3,146.58

Then the curl ....

curl -H "Authorization: ApiKey $EC_API_KEY" -X GET 'https://api.elastic-cloud.com/api/v1/billing/costs/<org_id>?from=2024-07-01T00:00:00Z&to=2024-07-29T00:00:00Z'

And the return shows...

{
    "trials": 0.0, 
    "costs": {
        "total": 3147.5603,  << Total 
        "dimensions": [
            {
                "cost": 2672.8862, 
                "type": "capacity"
            }, 
...

The difference is ~$1 or ~0.03% different which is reasonable / expected...

Try using my approach and perhaps they will align better

Name Type Required Description
from string N A datetime for the beginning of the desired range for which to fetch costs. Defaults to start of current month.
to string N A datetime for the end of the desired range for which to fetch costs. Defaults to the current date.

Ah, this makes sense! Thank you so much for all of your help! We appreciate your response!

1 Like