All Products
Search
Document Center

Container Service for Kubernetes:Enable Managed Service for Prometheus for AHPA

Last Updated:Apr 01, 2024

Alibaba Cloud Managed Service for Prometheus allows you to install and configure Advanced Horizontal Pod Autoscaler (AHPA) with a few clicks. Managed Service for Prometheus also provides out-of-the-box dashboards that you can use to monitor your applications. This topic describes how to enable Managed Service for Prometheus for AHPA.

Prerequisites

  • Managed Service for Prometheus is enabled for a Container Service for Kubernetes (ACK) cluster or ACK Serverless cluster. The version of the Prometheus agent is later than 3.0.0. For more information, see Enable Managed Service for Prometheus.

  • AHPA 2.0.0 or later is deployed. For more information, see Deploy AHPA.

  • The following code is added to the ConfigMap that is created for Managed Service for Prometheus:

    View details

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: application-intelligence
      namespace: kube-system
    data:
      prometheus_writer_url: http://cn-hangzhou-intranet.arms.aliyuncs.com/prometheus/190601496873****/cd5ec926b715e41b282296d1415a1***/cn-hangzhou/api/v3/write
      prometheus_writer_ak: xxx
      prometheus_writer_sk: xx
      ...

    • prometheus_writer_url: Specify the internal remote write endpoint of the Prometheus instance.

    • prometheus_writer_ak: Specify the AccessKey ID of the Alibaba Cloud account.

    • prometheus_writer_sk: Specify the AccessKey secret of the Alibaba Cloud account.

Limits

Only Prometheus instances of the Prometheus for Container Service type can be used to monitor AHPA.

Entry points

Entry point 1: Integration Center in the Managed Service for Prometheus console

  1. Log on to the Managed Service for Prometheus console.

  2. In the left-side navigation pane, click Monitoring List. On the Managed Service for Prometheus page, click the name of the Prometheus instance that you want to manage to go to the Integration Center page.

Entry point 2: Integration Center in the ARMS console

  1. Log on to the Application Real-Time Monitoring Service (ARMS) console.

  2. In the left-side navigation pane, click Integration Center. Then, click Install in the AHPA card in the Application Components section. In the panel that appears, set the parameters.

Configure Managed Service for Prometheus to monitor AHPA

The following steps describe how to configure Managed Service for Prometheus to monitor AHPA on the Integration Center page in the Managed Service for Prometheus console.

  1. Configure Managed Service for Prometheus to monitor AHPA.

    • If this is the first time you install AHPA, go to the Integration Center page and click Install in the AHPA card in the arms.common.status.IsNotInstalled section.

    • If AHPA is already installed, go to the Integration Center page and click Add in the AHPA card in the Installed section.

      Parameter

      Description

      Exporter Name

      The name must be unique among the exporters used to collect monitoring data from AHPA.

      Metrics space interval (seconds)

      The interval at which you want the exporter to collect monitoring data.

  2. In the STEP2 section, set the parameters and click OK.

    • You can view the monitoring metrics on the Metrics tab in the STEP2 section.

    • Components for which exporters are installed are displayed in the Installed section of the Integration Center page. You can click a card to view details on the Targets, Metrics, Dashboards, Alerts, Service Discovery Configurations, and Exporter tabs in the panel that appears.

View the AHPA dashboard

On the Integration Center page, click the AHPA card in the Installed section. Then, click the Dashboards tab and click ahpa-dashboard to go to the dashboard page.

The metrics displayed on the AHPA dashboard display the CPU utilization, the current number of pods, and the predicted number of pods.

  • The CPU Utilization & Actual POD chart displays the average CPU utilization and the current number of pods of the Deployment.

  • The Actual and Predicted CPU Usage chart displays the CPU usage of the pods in the Deployment and the predicted CPU usage. If the predicted CPU usage is higher than the current CPU usage, the CPU capacity predicted by AHPA is sufficient to run the application.

  • In the Pod Trends section, you can view the current number of pods, the recommended number of pods, and the proactively predicted number of pods.

    • Current number of pods: the number of pods that are running.

    • Recommended number of pods: the number of pods recommended by AHPA for the application. The value is generated based on the result of proactive prediction, the result of passive prediction, and the maximum and minimum numbers of pods within the current time period.

    • Proactively predicted number of pods: the number of pods proactively predicted by AHPA based on historical metric data and the pattern of workload fluctuations.

Key AHPA metrics

Metric

Description

ahpa_proactive_pods

The proactively predicted number of pods

ahpa_reactive_pods

The passively predicted number of pods

ahpa_requested_pods

The recommended number of pods

ahpa_max_pods

The maximum number of pods

ahpa_min_pods

The minimum number of pods

ahpa_target_metric

The scaling threshold

References

Resource demand is difficult to predict in cloud-native scenarios. Horizontal Pod Autoscaler (HPA) provided by Kubernetes scales resources with a scaling delay and the configuration is complex. To resolve the preceding issues, ACK supports predictive scaling based on AHPA. AHPA can automatically learn the pattern of workload fluctuations and predict resource demand based on historical metric data to help you implement predictive scaling. For more information about AHPA, see AHPA overview.