Sunday 11 June 2023

HPA Desired Pod Counts for All Services Summary - Grafana Chart with Azure Monitor for AKS

 Monitoring the desired pod count by each horizontal pod autoscaler for your application is useful to get a summarize view, that will help to understand scale out demand of each individual service. We can enable monitoring AKS cluster with Managed Grafana in Azure with Azure Monitor and Log Analytics Workspace. Let's write a query to and create Grafana chart for this purpose.

Expected Outcome

Each service scaling demand over time is shown as summary. This indicate based on load how each service in your application scale out is demanded by horizontal pod autoscaler.


We can use the query below to create the desired pod count summary panel in Grafana with Azure monitor.

InsightsMetrics
// | where $__timeFilter(TimeGenerated) // use only in grafana
| where Name == 'kube_hpa_status_current_replicas'
| extend pTags = todynamic(Tags)
| extend clusterName = todynamic(pTags["container.azm.ms/clusterName"])
| extend ns = todynamic(pTags.k8sNamespace)
| extend deployment_hpa = todynamic(pTags.targetName)
| extend desired_pods = todynamic(pTags.status_desired_replicas)
| where clusterName == "aks-chdemo-dev04"
| where ns == "mydemo"
| order by TimeGenerated asc
| project TimeGenerated, deployment_hpa, toint(desired_pods)

The full json for Grafana panel is available in GitHub here. You can replace the id of the panel and the subscription, log analytics workspace name, resource group name etc.


If you use the json in GitHub (Modify with your panel id, subscription id etc.) and use query inspector of the panel to replace json for panel the required settings will be automatically applied.






No comments:

Popular Posts