Collect Prometheus metrics from AKS cluster (preview)

This article describes how to configure your Azure Kubernetes Service (AKS) cluster to send data to Azure Monitor managed service for Prometheus. When you configure your AKS cluster to send data to Azure Monitor managed service for Prometheus, a containerized version of the Azure Monitor agent is installed with a metrics extension. You just need to specify the Azure Monitor workspace that the data should be sent to.

Note

The process described here doesn't enable Container insights on the cluster even though the Azure Monitor agent installed in this process is the same one used by Container insights. See Enable Container insights for different methods to enable Container insights on your cluster. See Collect Prometheus metrics with Container insights for details on adding Prometheus collection to a cluster that already has Container insights enabled.

Prerequisites

Enable Prometheus metric collection

Use any of the following methods to install the Azure Monitor agent on your AKS cluster and send Prometheus metrics to your Azure Monitor workspace.

  1. Open the Azure Monitor workspaces menu in the Azure portal and select your cluster.

  2. Select Managed Prometheus to display a list of AKS clusters.

  3. Select Configure next to the cluster you want to enable.

    Screenshot of Azure Monitor workspace with Prometheus configuration.

Enable windows metrics collection

As of version 6.4.0-main-02-22-2023-3ee44b9e, windows metric collection has been enabled for the AKS clusters. Onboarding to the Azure Monitor Metrics Addon will enable the windows daemonset pods to start running on your nodepools. Both Windows Server 2019 and Windows Server 2022 are supported. Follow the steps below to enable the pods to collect metrics from your windows node pools.

  1. Manually install the windows exporter on AKS nodes to access windows metrics. Enable the following collectors:

    • [defaults]
    • container
    • memory
    • process
    • cpu_info

    Deploy the windows-exporter-daemonset YAML file

        kubectl apply -f windows-exporter-daemonset.yaml
    
  2. Apply the ama-metrics-settings-configmap to your cluster, setting the windowsexporter and windowskubeproxy booleans to rue`. For more information, see Metrics addon settings configmap.

  3. While onboarding, enable the recording rules required for the default dashboards.

    • For CLI include the option --enable-windows-recording-rules.
    • For ARM template, Bicep, or Policy, set enableWindowsRecordingRules to true in the parameters file.

    If the cluster is already onboarded to Azure Monitor Metrics, to enable windows recording rule groups use this ARM template and Parameters file to create the rule groups.

Verify Deployment

Run the following command to verify that the DaemonSet was deployed properly on the linux nodepools:

kubectl get ds ama-metrics-node --namespace=kube-system

The number of pods should be equal to the number of nodes on the cluster. The output should resemble the following:

User@aksuser:~$ kubectl get ds ama-metrics-node --namespace=kube-system
NAME               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
ama-metrics-node   1         1         1       1            1           <none>          10h

Run the following command to verify that the DaemonSet was deployed properly on the windows nodepools:

kubectl get ds ama-metrics-win-node --namespace=kube-system

The output should resemble the following:

User@aksuser:~$ kubectl get ds ama-metrics-node --namespace=kube-system
NAME                   DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
ama-metrics-win-node   3         3         3       3            3           <none>          10h

Run the following command to which verify that the ReplicaSets were deployed properly:

kubectl get rs --namespace=kube-system

The output should resemble the following:

User@aksuser:~$kubectl get rs --namespace=kube-system
NAME                            DESIRED   CURRENT   READY   AGE
ama-metrics-5c974985b8          1         1         1       11h
ama-metrics-ksm-5fcf8dffcd      1         1         1       11h

Feature Support

  • ARM64 and Mariner nodes are supported.
  • HTTP Proxy is supported and will use the same settings as the HTTP Proxy settings for the AKS cluster configured with these instructions.

Limitations

  • CPU and Memory requests and limits can't be changed for Container insights metrics addon. If changed, they'll be reconciled and replaced by original values in a few seconds.
  • Azure Monitor Private Link (AMPLS) isn't currently supported.
  • Only public clouds are currently supported.

Uninstall metrics addon

Currently, Azure CLI is the only option to remove the metrics addon and stop sending Prometheus metrics to Azure Monitor managed service for Prometheus.

Install the aks-preview extension using the following command:

az extension add --name aks-preview

For more information on installing a CLI extension, see Use and manage extensions with the Azure CLI.

Note

Upgrade your az cli version to the latest version and ensure that the aks-preview version you're using is at least '0.5.132'. Find your current version using the az version.

az extension add --name aks-preview

Use the following command to remove the agent from the cluster nodes and delete the recording rules created for the data being collected from the cluster along with the Data Collection Rule Associations (DCRA) that link the DCE or DCR with your cluster. This doesn't remove the DCE, DCR, or the data already collected and stored in your Azure Monitor workspace.

az aks update --disable-azuremonitormetrics -n <cluster-name> -g <cluster-resource-group>

Region mappings

When you allow a default Azure Monitor workspace to be created when you install the metrics addon, it's created in the region listed in the following table.

AKS Cluster region Azure Monitor workspace region
australiacentral eastus
australiacentral2 eastus
australiaeast eastus
australiasoutheast eastus
brazilsouth eastus
canadacentral eastus
canadaeast eastus
centralus centralus
centralindia centralindia
eastasia westeurope
eastus eastus
eastus2 eastus2
francecentral westeurope
francesouth westeurope
japaneast eastus
japanwest eastus
koreacentral westeurope
koreasouth westeurope
northcentralus eastus
northeurope westeurope
southafricanorth westeurope
southafricawest westeurope
southcentralus eastus
southeastasia westeurope
southindia centralindia
uksouth westeurope
ukwest westeurope
westcentralus eastus
westeurope westeurope
westindia centralindia
westus westus
westus2 westus2
westus3 westus
norwayeast westeurope
norwaywest westeurope
switzerlandnorth westeurope
switzerlandwest westeurope
uaenorth westeurope
germanywestcentral westeurope
germanynorth westeurope
uaecentral westeurope
eastus2euap eastus2euap
centraluseuap westeurope
brazilsoutheast eastus
jioindiacentral centralindia
swedencentral westeurope
swedensouth westeurope
qatarcentral westeurope

Next steps