Skip to content

[AKS] Add --enable-control-plane-metrics and --disable-control-plane-metrics for Managed Prometheus#3

Open
bragi92 wants to merge 1 commit intodevfrom
feature/control-plane-metrics
Open

[AKS] Add --enable-control-plane-metrics and --disable-control-plane-metrics for Managed Prometheus#3
bragi92 wants to merge 1 commit intodevfrom
feature/control-plane-metrics

Conversation

@bragi92
Copy link
Copy Markdown
Owner

@bragi92 bragi92 commented Apr 15, 2026

Description

Add CLI support for the new Control Plane Metrics feature in the Azure Managed Prometheus addon. This enables collection of operational runtime metrics from managed control plane components (kube-apiserver, etcd, etc.) via the ManagedClusterAzureMonitorProfileMetricsControlPlane model.

Background

This is part of the CCP Metrics GA plan. The feature transitions from a preview feature-flag-based enablement to an explicit opt-in via a new controlPlane property on the ManagedClusterAzureMonitorProfileMetrics model.

New CLI Parameters

Parameter Command Type Description
--enable-control-plane-metrics az aks create bool Enable control plane metrics when creating a cluster with --enable-azure-monitor-metrics
--disable-control-plane-metrics az aks create bool Explicitly disable control plane metrics at create time
--enable-control-plane-metrics az aks update bool Enable control plane metrics on an existing cluster (requires Azure Monitor Metrics to be enabled)
--disable-control-plane-metrics az aks update bool Disable control plane metrics on an existing cluster

CLI Usage Examples

Enable on new cluster:

az aks create --enable-azure-monitor-metrics \
  --name <cluster-name> \
  --resource-group <resource-group> \
  --enable-control-plane-metrics

Enable on existing cluster (metrics already enabled):

az aks update --name <cluster-name> \
  --resource-group <resource-group> \
  --enable-control-plane-metrics

Enable both monitor metrics and control plane on existing cluster:

az aks update --enable-azure-monitor-metrics \
  --name <cluster-name> \
  --resource-group <resource-group> \
  --enable-control-plane-metrics

Disable control plane metrics:

az aks update --name <cluster-name> \
  --resource-group <resource-group> \
  --disable-control-plane-metrics

Validation Rules

  1. Cannot use standalone: --enable-control-plane-metrics cannot be used without --enable-azure-monitor-metrics on create, or without Azure Monitor Metrics already being enabled on the cluster for update. Error:

    --enable-control-plane-metrics cannot be used as a standalone flag. This flag must be used in conjunction with --enable-azure-monitor-metrics to enable control plane metrics collection.

  2. Mutual exclusivity: --enable-control-plane-metrics and --disable-control-plane-metrics cannot be specified together.

  3. Disable requires metrics: --disable-control-plane-metrics requires Azure Monitor Metrics to be enabled on the cluster.

ARM Model Shape

{
  "azureMonitorProfile": {
    "metrics": {
      "enabled": true,
      "controlPlane": {
        "enabled": true
      },
      "kubeStateMetrics": { }
    }
  }
}

Files Changed

File Changes
_params.py Added enable_control_plane_metrics and disable_control_plane_metrics to both create and update command groups
custom.py Added new parameters to aks_create() and aks_update() function signatures
managed_cluster_decorator.py Added getter/validator methods with validation (mutual exclusivity, requires monitor metrics). Updated set_up_azure_monitor_profile (create) and update_azure_monitor_profile (update) to set control_plane on the metrics object
_help.py Added help text for all new parameters in both create and update commands

Customer Scenarios Covered

# Scenario Behavior
1 New cluster with control plane metrics az aks create --enable-azure-monitor-metrics --enable-control-plane-metrics enables API Server and ETCD metrics
2 Existing cluster, add control plane metrics az aks update --enable-control-plane-metrics (if monitor metrics already enabled)
3 Preview to GA transition Existing preview customers backfilled via regional looper; controlPlane.enabled=true set automatically
4 Without monitor metrics addon az aks create --enable-control-plane-metrics alone gives error with guidance to enable monitor metrics first
5 Disable control plane metrics az aks update --disable-control-plane-metrics stops collection while keeping monitor metrics enabled

Known Blockers

SDK dependency: ManagedClusterAzureMonitorProfileMetricsControlPlane does not yet exist in azure-mgmt-containerservice. Current pin is 41.0.0 and latest beta 41.1.0b1 also does not include it. This PR is ready for review but cannot be merged or tested end-to-end until the SDK is updated.

TODO (post SDK availability)

  • Bump azure-mgmt-containerservice version in setup.py
  • Add unit tests in test_managed_cluster_decorator.py
  • Add integration test recordings
  • Verify end-to-end with a live cluster

Related

@github-actions
Copy link
Copy Markdown

The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR.

Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

…metrics for Managed Prometheus

Add CLI support for the ManagedClusterAzureMonitorProfileMetricsControlPlane
feature, which enables collection of control plane component metrics
(kube-apiserver, etcd, etc.) via the Azure Managed Prometheus addon.

Changes:
- Add --enable-control-plane-metrics param for aks create and update
- Add --disable-control-plane-metrics param for aks create and update
- Add getter/validator methods with mutual exclusivity checks
- Add validation: control plane metrics flags require --enable-azure-monitor-metrics
  or that Azure Monitor Metrics is already enabled on the cluster
- Wire control_plane into set_up/update_azure_monitor_profile decorators
- Add help text for all new parameters

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bragi92 bragi92 force-pushed the feature/control-plane-metrics branch from f98d968 to b88da59 Compare April 16, 2026 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant