cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Get Started Discussions
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

using the api for getting cost in usd

hpicatto
New Contributor III

I'm trying to use the API of billable usage and I do get a report but I have not been able to get the usd cost report, only the dbuHours. I guess I've to change the meter_name but I cannot find the key for that parameter anywhere

3 REPLIES 3

Kaniz
Community Manager
Community Manager

Hi @hpicatto , When working with the Azure Consumption API to retrieve usage details, you can indeed obtain cost information by specifying the correct meter name.

Letโ€™s dive into the details:

  1. First, ensure that youโ€™re using the Cost Details API instead of the Consumption Usage Details API. The latter is being retired, and the former provides more comprehensive cost-related data.

  2. To retrieve cost information, youโ€™ll need to include the meter_name parameter in your API request. Hereโ€™s how you can structure the request:

    GET /{scope}/providers/Microsoft.Consumption/usageDetails
    ?$expand={$expand}
    &$filter={$filter}
    &$skiptoken={$skiptoken}
    &$top={$top}
    &api-version=2023-05-01
    &metric={metric}
    
    • {scope}: Replace this with the appropriate scope (e.g., subscription, billing account, department, etc.). You can also add the billing period to the scope if needed.
    • $expand: Use this query parameter to expand specific properties (such as additionalInfo or meterDetails) within the list of usage details. By default, these fields are not included.
    • $filter: You can filter usage details based on various properties such as resource group, resource name, charge type, reservation ID, publisher type, or tags.
    • api-version: Specify the version of the API (e.g., 2023-05-01).
    • metric: This is where youโ€™ll provide the meter_name youโ€™re interested in.
  3. Now, letโ€™s find the appropriate meter_name for your use case. The meter_name identifies the specific meter (or usage type) associated with the consumption. Here are a couple of examples:

    • Meter Name: โ€œPremium Storage - Page Blob/P10 (Units)โ€

      • Meter Category: Storage
      • Meter Subcategory: Locally Redundant
      • Meter Region: California
    • Meter Name: โ€œCompute Hoursโ€

      • Meter Category: Compute
      • Meter Subcategory: Virtual Machines
      • Meter Region: Global

    You can explore more meter names based on your requirements. Keep in mind that each meter corresponds to a specific service or resource type within Azure.

Remember to replace the placeholders with actual values relevant to your scenario. If you encounter any issues or need further assistance, feel free to ask! ๐Ÿ˜Š

For detailed reference, you can check out the Azure Consumption API documentation1.

 

hpicatto
New Contributor III

thanks, how about the aws one

Kaniz
Community Manager
Community Manager

Hi @hpicatto,

AWS Usage Reports:

AWS provides detailed usage and cost reports through the AWS Cost and Usage Report. You can access this report via the AWS Management Console. Here are the steps:

  1. Log in to the AWS Management Console.
  2. Navigate to the Billing Dashboard.
  3. Click on Cost & Usage Reports.
  4. Create a new report or modify an existing one.
  5. Specify the desired granularity (e.g., hourly, daily) and other settings.
  6. Once the report is generated, you can download it in CSV or Parquet format.

The AWS report includes information about usage, costs, and resource utilization. You can customize the report to suit your requirements.

Remember that both Azure and AWS provide comprehensive documentation, so feel free to explore further based on your specific needs! ๐Ÿš€

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.