All Products
Search
Document Center

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

Last Updated:Nov 26, 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. The version of the Prometheus agent is later than 3.0.0. For more information, see Step 1: Enable Managed Service for Prometheus.

  • Advanced Horizontal Pod Autoscaler (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.

Step 1: Integrate AHPA

You can perform the following steps to integrate the AHPA component to Managed Service for Prometheus.

  1. Log on to the ARMS console.

  2. In the left-side navigation pane, click Integration Center. On the page that appears, enter AHPA in the search box.

  3. Click the AHPA card. On the page that appears, select the ACK cluster to be accessed and configure the parameters according to the instructions.

    Parameter

    Description

    Name

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

    metrics collection interval (seconds)

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

View the AHPA dashboard

  1. Log on to the ARMS console.

  2. In the left-side navigation pane, click Integration Management, and then click the Integrated Addons tab.

  3. Click the AHPA card. On the page that appears, click the Dashboards tab, and then click the name of the dashboard to view the details of the dashboard in Grafana.

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

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

  • Actual and Predicted CPU Usage: 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.

  • Pod Trends: displays the actual number of pods, recommended number of pods, and 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 the best practices for AHPA, see Best practices for auto scaling.