Share via

How to calculate the cpu and memory cost separately from the total node cost?

Padmanabhan M 220 Reputation points
2026-03-23T14:22:20.5866667+00:00

Currently i am getting the node cost using the retail api by passing vm size, ostype, location etc.
I want to calculate the cpu and memory cost separately for a node from this total cost.
Can we do that?

currently i am extracting metrics like..

memoryworkingsetbytes, cpuusagenanocores, cpuallocatablenanocores, cpucapacitynanocores, memorycapacitybytes, memoryallocatablebytes.

Cost Management
Cost Management

A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.


Answer accepted by question author

Bharath Y P 9,110 Reputation points Microsoft External Staff Moderator
2026-03-23T17:45:46.49+00:00

You are retrieving total VM/node cost from the Azure Retail Prices API by passing parameters like VM size, OS type, and location. You want to know if it’s possible to separate CPU and memory costs from this total cost using metrics such as cpuusagenanocores, memoryworkingsetbytes, etc.Azure VM pricing is SKU-based, meaning Microsoft charges for the combination of CPU, memory, storage, and networking bundled in that VM size. Microsoft does not provide separate cost components for CPU, memory, or storage in the Retail Prices API. The SKU price is a single figure representing the whole package. Since no per-resource cost is published, there’s no authoritative way to isolate CPU vs memory cost.https://learn.microsoft.com/en-us/azure/aks/cost-analysis

As per your request you can calculate pod usage first and then allocate pod cost from the node cost using the metrics you already have.

If You said you have Node total cost (per hour / per day) and  Pod metrics like CPU usage, Memory usage, CPU request and Memory request. Using this you can compute pod usage share and pod cost.

Split node cost into CPU and memory components: Cloud providers don’t give “CPU price” and “memory price” separately, so you must derive a ratio.

Split node cost proportionally by capacity:

CPU cost weight  = Node vCPU / (Node vCPU + Node Memory GB) Memory cost weight = Node Memory GB / (Node vCPU + Node Memory GB)

Then:

Node CPU cost  = Node total cost × CPU weight Node Memory cost = Node total cost × Memory weight

Calculate pod’s share of node resources

Pod CPU share = Pod CPU request / Σ (CPU requests of all pods on node) Pod Memory share = Pod Memory request / Σ (Memory requests of all pods on node)

Calculate pod cost

Pod CPU cost = Pod CPU share × Node CPU cost Pod Memory cost = Pod Memory share × Node Memory cost

Final pod cost: 

Plain Text

Pod total cost = Pod CPU cost + Pod Memory cost

Thank You.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. AI answer

    2026-03-23T14:22:38.9233333+00:00

    Azure retail prices for a VM/node are exposed as a single meter price per SKU (for example, a specific VM size in a region). The Cost Management Retail Prices API returns properties such as retailPrice, unitPrice, productName, and skuName for that SKU, but it does not break the price down into separate CPU and memory components.

    Because of that, the platform does not provide an official or supported way to decompose the node (VM) price into distinct “CPU cost” and “memory cost” using the retail API alone. The metrics being collected from AKS (for example, cpuusagenanocores, memoryworkingsetbytes, cpucapacitynanocores, memorycapacitybytes) describe utilization and capacity, not pricing dimensions, so they cannot be mapped directly to separate CPU and memory prices from the retail API.

    If a split is needed, it must be done using a custom allocation model, for example:

    • Define an internal ratio (such as 60% of the VM price attributed to CPU and 40% to memory) based on organizational assumptions or benchmarking.
    • Use the node’s total retail price from the API and multiply by that ratio to derive “CPU cost” and “memory cost”.
    • Optionally weight costs across workloads by their relative CPU or memory usage using the AKS metrics, but this remains a custom model, not an Azure billing breakdown.

    There is no built-in Azure mechanism or API parameter that returns separate CPU and memory prices for a node.


    References:

    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.