Azure Kubernetes Service(AKS) - How Pod CPU and Memory Usage (%) metrics are derived

Azure Kubernetes Service(AKS) - How Pod CPU and Memory Usage (%) metrics are derived

Overview

Notes
Note: Pod CPU & Memory Usage (%) metrics are supported from Applications Manager v17.81.00
      This KB explains how the Pod CPU Usage (%) and Pod Memory Usage (%) metrics shown in the Pods tab → Pod CPU and Memory Usage table are derived. The metrics are calculated using three different methods, each providing a unique monitoring perspective based on:
      1. Pod Limit (Recommended)
      2. Pod Request
      3. Node Allocatable
         

Pod Usage (%) Calculation Methods

  1. Pod Limit based Calculation

    1. Formulas:
      1. Pod CPU Usage(%) = (Pod CPU Used(millicores) / Pod CPU Limit(millicores)) × 100
      2. Pod Memory Usage(%) = (Pod Memory Used(MiB) / Pod Memory Limit(MiB)) × 100
    2. Purpose: The Usage (%) calculation based on the Pod limit helps monitoring performance efficiency and potential throttling risks.
    3. The recommended and default method for deriving Pod Usage (%) is by using Pod Limits.
  2. Pod Request based Calculation

    1. Formulas:
      1. Pod CPU Usage(%) = (Pod CPU Used(millicores) / Pod CPU Request(millicores)) × 100
      2. Pod Memory Usage(%) = (Pod Memory Used(MiB) / Pod Memory Request(MiB)) × 100
    2. Purpose: The Usage (%) calculation based on the Pod request helps monitoring resource efficiency and rightsizing opportunities.
  3. Node based Calculation

    1. Formulas:
      1. Pod CPU Usage(%) = (Pod CPU Used(millicores) / Node's Allocatable CPU(millicores)) × 100
      2. Pod Memory Usage(%) = (Pod Memory Used(MiB) / Node's Allocatable Memory(MiB)) × 100
    2. Purpose: The Usage (%) calculation based on the Node allocatable helps monitoring pod utilization and capacity planning at the node level.

How are the Pod metrics retrieved?

      All metrics used in these calculations are fetched from 'kubectl' commands
    1. Pod CPU and Memory Consumption
      1. Command: kubectl top pod --all-namespaces
      2. Retrieved Metrics:
        1. Pod CPU Used(millicores): Current CPU consumption by each pod.
        2. Pod Memory Used(MiB): Current memory consumption by each pod.
    2. Pod Resource Limits and Node Capacity
      1. Command: kubectl describe nodes
      2. Retrieved Metrics:
        1. Pod CPU Limit(millicores): Maximum CPU each pod can use.
        2. Pod Memory Limit(MiB): Maximum memory each pod can use.
        3. Pod CPU Request(millicores): Guaranteed CPU allocation for each pod.
        4. Pod Memory Request(MiB): Guaranteed memory allocation for each pod.
        5. Node's Allocatable CPU(millicores): Available CPU capacity on each node.
        6. Node's Allocatable Memory(MiB): Available memory capacity on each node.
                                                           

How to configure the calculation method?

      The calculation method can be configured by updating the Global Config key in the AM_GLOBALCONFIG table.
    1. Global Config Key: am.cloud.azure.aks.pod.usage.calculation
    2. Possible Values:
      1. podlimits – Pod limit based calculation
      2. podrequests – Pod request based calculation
      3. nodeallocatable – Node allocatable based calculation
    3. Default Behavior: By default, the global config key does not exist. In this case, the Pod CPU and Memory Usage (%) calculation is based on Pod Limits.
    4. Steps to configure: Open the query tool and perform the below steps.
      1. Verify Key Existence: Check whether the key 'am.cloud.azure.aks.pod.usage.calculation' exists in the AM_GLOBALCONFIG table.
        1. SELECT * FROM AM_GLOBALCONFIG WHERE NAME = 'am.cloud.azure.aks.pod.usage.calculation';
      2. If the key does not exist, to switch the calculation method perform an INSERT operation.
        1. INSERT INTO AM_GLOBALCONFIG (NAME, VALUE) VALUES ('am.cloud.azure.aks.pod.usage.calculation', 'podrequests');
      3. If the key exists, perform an UPDATE operation to switch the calculation method.
        1. UPDATE AM_GLOBALCONFIG  SET VALUE = 'nodeallocatable' WHERE NAME = 'am.cloud.azure.aks.pod.usage.calculation';


                  New to ADSelfService Plus?

                    • Related Articles

                    • Azure Kubernetes Service(AKS) Troubleshooting FAQs

                      Azure Kubernetes Service (AKS) monitor can be configured only if you have already added a Microsoft Azure monitor in Applications Manager. Ensure that you have met all the prerequisites for the Microsoft Azure monitor before monitoring Azure ...
                    • How to connect Azure Kubernetes Service(AKS) Cluster and run Kubectl commands

                      This KB has information about connecting the Azure Kubernetes Cluster using Azure CLI and kubectl commands. Verify both Azure CLI and kubectl are configured in Applications Manager installed server as mentioned in our prerequisites. This document ...
                    • Microsoft Azure VM - Enabling Diagnostics extension for Windows & Linux VMs

                      Diagnostic Extension is now considered a legacy approach and it is limited to some server distributions. It is recommended to switch to Azure Monitor Agent (AMA). From Applications Manager v171400, Azure monitor agent is supported. Refer here to know ...
                    • How to install .NET agent on Azure app services?

                      You can track the performance of your .NET and .NET Core web app's key metrics like response time, throughput, and Apdex score via the APM Insight .NET agent hosted in Azure App Services. Installing APM Insight extension via Azure portal 1. Log in to ...
                    • Memory Usage Calculation (Linux- Telnet/SSH)

                      Physical Memory Utilization Calculation: Note: For version 16800 and above , the Skip option will be under Settings -> Performance Polling -> Servers -> Linux monitor type. Formula: (i) If Skip buffer and cache from monitoring (Applicable only for ...