A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
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.