Skip to content

Commit ff03fba

Browse files
committed
AKS: Add control plane metrics article
1 parent 61cb92e commit ff03fba

File tree

6 files changed

+144
-0
lines changed

6 files changed

+144
-0
lines changed

AKS-Arc/control-plane-metrics.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
---
2+
title: Monitor control plane metrics
3+
description: Learn how to enable and query control plane metrics from AKS on Azure Local 23H2.
4+
ms.date: 03/26/2025
5+
ms.topic: how-to
6+
author: sethmanheim
7+
ms.author: sethm
8+
ms.reviewer: haojiehang
9+
10+
---
11+
12+
# Monitor control plane metrics
13+
14+
[!INCLUDE [hci-applies-to-23h2](includes/hci-applies-to-23h2.md)]
15+
16+
This article describes how to enable and query control plane metrics from AKS on Azure Local 23H2. The workflow is as follows:
17+
18+
- Enable Managed Prometheus extension
19+
- Enable control plane metrics
20+
- (Optional) view metrics in Grafana
21+
22+
Control plane metrics provide critical visibility into the availability and performance of Kubernetes control plane components, such as the API server, scheduler, or controller manager. You can use these metrics to maximize observability and maintain operational excellence for your cluster.
23+
24+
## Prerequisites
25+
26+
Before you begin, make sure the following prerequisites are met:
27+
28+
- A running AKS on Azure Local instance.
29+
- Install the latest version of the **aksarc****connectedk8s**, and **k8s-extension** CLI extensions.
30+
- [Download and install **kubectl**](https://kubernetes.io/docs/tasks/tools/) on your development machine.  
31+
- [Understand the basics of Prometheus Query Language](https://prometheus.io/docs/prometheus/latest/querying/examples/).
32+
- [Understand the basics of Kubernetes system component metrics](https://kubernetes.io/docs/concepts/cluster-administration/system-metrics/).
33+
34+
## Enable Managed Prometheus extension
35+
36+
Azure Monitor collects and aggregates important metrics from your AKS Arc running on Azure Local instance. In addition to [platform metrics](kubernetes-monitor-metrics.md#metrics) collected from your cluster, you can view granular Kubernetes metrics using the managed Prometheus extension. This extension collects Prometheus metrics from your deployment and stores them in an Azure Monitor workspace in Azure. Once they are ingested, you can analyze them in Metrics Explorer or use prebuilt dashboards in Azure Managed Grafana.
37+
38+
### Step 1: Install the managed Prometheus extension
39+
40+
You can either install the extension from the Azure portal or using CLI.
41+
42+
#### Portal
43+
44+
Go to your Kubernetes instance, then select **Monitoring > Insights > Monitor Settings**.
45+
46+
:::image type="content" source="media/control-plane-metrics/monitor-settings.png" alt-text="Screenshot of portal showing monitor settings." lightbox="media/control-plane-metrics/monitor-settings.png":::
47+
48+
#### CLI
49+
50+
The following command installs the managed Prometheus extension with a default Azure Monitor workspace.
51+
52+
```azurecli
53+
az k8s-extension create --name azuremonitor-metrics --cluster-name <cluster-name> --resource-group <resource-group> --cluster-type connectedClusters --extension-type Microsoft.AzureMonitor.Containers.Metrics
54+
```
55+
56+
The guidance for the managed Prometheus extension onboarding can also be found [here](/azure/azure-monitor/containers/kubernetes-monitoring-enable?tabs=cli#enable-prometheus-and-grafana).
57+
58+
### Step 2: Verify extension and metrics pod deployment
59+
60+
To verify the extension installation, you can run `az connectedk8s proxy` to connect to the cluster and use **kubectl** to list the metrics pods. The pods should start with the name **ama-metrics-** and are in a running state.
61+
62+
```azurecli
63+
kubectl get pods -n kube-system
64+
```
65+
66+
The output of the command is similar to the following:
67+
68+
```output
69+
NAME READY STATUS RESTARTS AGE
70+
akshci-telemetry-5df56fd5-s5wtm 1/1 Running 1 (37h ago) 44d
71+
ama-logs-nqf9h 3/3 Running 0 5h29m
72+
ama-logs-pvvb2 3/3 Running 2 (5h21m ago) 5h29m
73+
ama-logs-rs-86bc9dd898-4p7pv 2/2 Running 0 5h29m
74+
**ama-metrics-98bb54876-dndrh** 2/2 Running 2 (3h33m ago) 5h30m
75+
**ama-metrics-ksm-6544c98f5f-ph6sp** 1/1 Running 0 5h30m
76+
**ama-metrics-node-6dl7p** 2/2 Running 2 (3h33m ago) 5h30m
77+
**ama-metrics-node-ztwzt** 2/2 Running 1 (3h33m ago) 5h30m
78+
….
79+
```
80+
81+
## Enable control plane metrics with custom configurations
82+
83+
After enabling the extension, you can view Prometheus Metrics from [targets scraped by default](/azure/azure-monitor/containers/prometheus-metrics-scrape-default#targets-scraped-by-default) in the Azure Monitor workspace. The [default ON targets](/azure/azure-monitor/containers/prometheus-metrics-scrape-configuration-minimal#minimal-ingestion-for-default-on-targets) include kubelet, kube-state-metrics, node-exporter, etc. To get started with kubelet metrics, use the PromQL below:
84+
85+
```bash
86+
kubelet_running_pods{cluster="<cluster_name>", instance="<instance_name>", job="kubelet"}
87+
```
88+
89+
:::image type="content" source="media/control-plane-metrics/metrics.png" alt-text="Screenshot showing metrics query." lightbox="media/control-plane-metrics/metrics.png":::
90+
91+
To view control plane metrics such as APIServer, ETCD, you need to customize the scraping of Prometheus metrics by applying the config maps to your cluster. The metrics pods pick up the config maps and pods restart in 2-3 minutes. Follow these steps to enable.
92+
93+
### Step 1: connect to Kubernetes
94+
95+
Connect to your cluster using `az connectedk8s proxy` and run `kubectl get pods -A` to make sure you're connected.
96+
97+
### Step 2: download the configuration files and review the content
98+
99+
Managed Prometheus uses an [agent-based solution](https://github.com/Azure/prometheus-collector) to collect Prometheus metrics and send them to the Azure Monitor workspace. There are two configuration files to download and review: **ama-metrics-settings-configmap.yaml** and **ama-metrics-prometheus-config-configmap.yaml**. For more information about customizing metrics scraping using configuration files, see [Customize scraping of Prometheus metrics](/azure/azure-monitor/containers/prometheus-metrics-scrape-configuration).
100+
101+
- To enable **APIServer** metrics, modify the value of `apiserver` under the default OFF targets and set it to **true** in **ama-metrics-settings-configmap.yaml**. For the list of metrics, see [minimal ingestion for default OFF targets](/azure/azure-monitor/containers/prometheus-metrics-scrape-configuration-minimal#minimal-ingestion-for-default-off-targets).
102+
- To enable metrics from components not listed under default OFF targets such as **ETCD, Controller Manager, Kube Scheduler**, add a new scraping job in **ama-metrics-prometheus-config-configmap.yaml**.
103+
104+
[You can download](https://github.com/Azure/aksArc/tree/main/scripts/ControlPlaneMetrics) these two configuration files to your local machine and review the content before going to the next step.
105+
106+
### Step 3: apply custom configuration files
107+
108+
Run the following commands to apply the changes, then wait for several minutes for the metrics pods to restart.
109+
110+
```bash
111+
kubectl apply -f ama-metrics-settings-configmap.yaml
112+
kubectl apply -f ama-metrics-prometheus-config-configmap.yaml
113+
```
114+
115+
### Step 4: query metrics in Azure Monitor workspace
116+
117+
Go to the linked **Azure Monitor Workspace > Metric Explorer** and use PromQL to validate that the metrics are ingested. In the following sample query, it shows a stable kube-scheduler metrics `scheduler_schedule_attempts_total` from a specific Kubernetes cluster.
118+
119+
:::image type="content" source="media/control-plane-metrics/metrics-ingested.png" alt-text="Screenshot of portal showing metrics ingestion." lightbox="media/control-plane-metrics/metrics-ingested.png":::
120+
121+
## View metrics in Grafana
122+
123+
Metrics Explorer is convenient for metrics validation. To operationalize Kubernetes monitoring with Azure Monitor, it's recommended that you monitor the metrics using Azure Managed Grafana.
124+
125+
### Step 1: install Azure Managed Grafana
126+
127+
[Follow these instructions](/azure/managed-grafana/how-to-connect-azure-monitor-workspace) to create a Grafana workspace, link to an Azure Monitor workspace, and view the metrics in Grafana dashboards. You can view the dashboard under **Monitoring > Insights > Monitor Settings**. Multiple instances can be linked to the same Azure Monitor workspace, so make sure to choose the right dashboard.
128+
129+
### Step 2: import a prebuilt dashboard for control plane metrics
130+
131+
[Download the API server dashboard ](https://grafana.com/grafana/dashboards/20331-kubernetes-api-server/) to your local machine, copy the JSON content, then import it to the managed Grafana dashboard.
132+
133+
:::image type="content" source="media/control-plane-metrics/dashboards.png" alt-text="Screenshot showing metrics dashboard." lightbox="media/control-plane-metrics/dashboards.png":::
134+
135+
### Step 3: View metrics in the dashboard
136+
137+
Ensure that the data source and cluster names are correct. You can view the metrics in Grafana and customize them as needed.
138+
139+
:::image type="content" source="media/control-plane-metrics/metrics-status.png" alt-text="Screenshot showing control plance metrics status." lightbox="media/control-plane-metrics/metrics-status.png":::
140+
141+
## Next Steps
142+
143+
- [AKS Arc monitoring data reference](kubernetes-monitor-metrics.md)
144+
- [Prometheus scrape configuration](/azure/azure-monitor/containers/prometheus-metrics-scrape-configuration)
86.1 KB
Loading
128 KB
Loading
916 KB
Loading
147 KB
Loading
545 KB
Loading

0 commit comments

Comments
 (0)