All Products
Search
Document Center

Elastic Container Instance:Enable Managed Service for Prometheus for an ACK Serverless cluster

Last Updated:Apr 03, 2024

After you enable Managed Service for Prometheus for a Kubernetes cluster, you can use the predefined dashboards to monitor the performance metrics of the Kubernetes cluster. This topic describes how to enable Managed Service for Prometheus for a Container Service for Kubernetes (ACK) Serverless cluster. This way, you can use Prometheus to monitor Elastic Container Instance-based pods in the cluster.

Prerequisites

  • An ACK Serverless cluster is created.

    Note

    If the security group in the cluster is not automatically created but manually configured, make sure that ports 8080, 8081, and 9335 are enabled on the security group.

  • The Application Real-Time Monitoring Service (ARMS) service is activated. For more information, see Activate ARMS.

    Note

    Managed Service for Prometheus is a paid sub-service of ARMS. For more information, see ARMS pricing page.

Background information

Managed Service for Prometheus is a managed monitoring service that is provided by Alibaba Cloud. Managed Service for Prometheus is compatible with the open source Prometheus ecosystem. Managed Service for Prometheus provides out-of-the-box dashboards for you to monitor a wide variety of components. Managed Service for Prometheus allows you to implement monitoring on applications without building a Prometheus monitoring system. You do not need to worry about issues such as underlying data storage, data display, and system O&M. For more information, see What is Managed Service for Prometheus?

Install the Prometheus Service agent

  1. Log on to the ACK console.

  2. In the left-side navigation pane, click Clusters.

  3. On the Clusters page, click the name of the cluster for which you want to install the agent.

  4. In the left-side navigation pane of the cluster management page, choose Operations > Add-ons.

  5. Click the Logs and Monitoring tab, find the card of ack-arms-Prometheus, and then click Install.

  6. In the message that appears, click OK.

    After the Prometheus Service agent is installed, Installed is displayed in the upper-right corner of the ack-arms-prometheus card.

View Prometheus Monitoring metrics

After the Prometheus Service agent is installed, you can view the detailed monitoring information on the Prometheus Service page in the ARMS console.

  1. In the left-side navigation pane of the ACK console, click Clusters.

  2. On the Clusters page, click the name of the cluster whose monitoring metrics you want to view.

  3. On the Overview tab of the Cluster Information page, click Prometheus Monitoring in the upper-right corner.

  4. View Prometheus Monitoring metrics.

    You can switch tabs to view the metrics displayed on different boards. For more information, see View Grafana metrics.

    pro监控..png

    By clicking Go to ARMS Prometheus in the upper-right corner, you can go to the ARMS console and configure the Prometheus dashboard for the cluster.

    监控大盘..png

Configure a data collection rule for Prometheus Monitoring

ARMS Prometheus is compatible with and provides three types of mainstream collection rules:

  • The standard open source collection rule, which can be obtained by editing the prometheus.yaml file.

  • The collection rule that is suitable for custom monitoring within Kubernetes clusters. This rule can be obtained by adding a ServiceMonitor.

  • The default collection rule, which can be obtained by adding annotations.

You can configure the three types of rules by using the following methods:

  • Edit prometheus.yaml

    You do not need to restart Prometheus Monitoring. You can dynamically update a collection rule by editing the prometheus.yaml file.

    1. In the left-side navigation pane of the ARMS console, choose Managed Service for Prometheus > Instances.

    2. In the instance list, find the Prometheus instance for which you want to configure the collection rule. The name of the Prometheus instance is the same as the name of the ACK Serverless cluster. Click Settings in the Actions column.

    3. In the left-side navigation pane, click Settings.

    4. On the Settings tab, click Edit Prometheus.yaml.

    5. Edit the prometheus.yaml file and click Save.

      Sample content:

      global:
        scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
        evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
      scrape_configs:
        - job_name: 'prometheus'
          static_configs:
          - targets: ['localhost:9090']
  • Add a ServiceMonitor

    After you add a ServiceMonitor, you can monitor business data of applications within a Kubernetes cluster.

    1. In the left-side navigation pane of the ARMS console, choose Managed Service for Prometheus > Instances.

    2. In the instance list, find the Prometheus instance for which you want to configure the collection rule. The name of the Prometheus instance is the same as the name of the ACK Serverless cluster. Click Settings in the Actions column.

    3. In the left-side navigation pane, click Service Discovery. Then, click the Configurations tab.

    4. Click the ServiceMonitor tab. Then, click Add ServiceMonitor.

    5. Enter information by referring to the following example and click OK:

      apiVersion: monitoring.coreos.com/v1
      kind: ServiceMonitor
      metadata:
        # Enter a unique name.
        name: tomcat-demo
        # Enter a namespace.
        namespace: default
      spec:
        endpoints:
        - interval: 30s
          # Enter the value of the Name field of the Port parameter of the Prometheus exporter.
          port: tomcat-monitor
          # Enter the value of the Path field of the Prometheus exporter.
          path: /prometheus-metrics
        namespaceSelector:
          any: true
        selector:
          matchLabels:
            # Enter the label field of service.yaml to locate the destination service.yaml file.
            app: tomcat
  • Add annotations

    In the YAML file of the application, enter the following content to add annotations:

    annotations:
              prometheus.io/scrape: "true"
              prometheus.io/port: "9090"
              prometheus.io/path: "/metrics"