All Products
Search
Document Center

Managed Service for Prometheus:Default service discovery

Last Updated:May 21, 2024

You can enable the default service discovery feature to collect metrics that comply with the default collection rules of Prometheus from Container Service for Kubernetes (ACK) clusters. This helps you implement cluster O&M and performance analysis.

Limits

Only ACK environment instances are supported.

Fees

The default service discovery feature charges fees. For more information, see Billing.

Prerequisites

  • An ACK environment instance (ACK cluster) is created. For more information, see Create an ACK managed cluster.

  • The ACK cluster is connected to Alibaba Cloud Managed Service for Prometheus by using the integration center. For more information, see Use the integration center to integrate data.

    Important

    If the ACK cluster is not connected to Managed Service for Prometheus by using the integration center, the default service discovery feature fails to be enabled.

  • Annotations that comply with the default collection rules of Prometheus are configured for the pods whose metrics need to be exposed in the cluster.

Step 1: Add annotations

  1. Log on to the ACK console.

  2. On the Clusters page, click the name of the cluster that you want to manage and choose Workloads > Pods in the left-side navigation pane.

  3. Find the pod and click Edit in the Actions column to add the following annotations:

    annotations:
      prometheus.io/path: /metrics # The HTTP path where you want to expose the metrics. 
      prometheus.io/port: "xxxx" # The port on which you want to expose the metrics. 
      prometheus.io/scrape: "true" # Specify whether to capture the metrics.
  4. Click Update.

Step 2: Enable default service discovery

  1. In the left-side navigation pane, click Integration Management.

  2. On the Integrated Environments tab, view the environment list on the Container Service tab. Find the ACK environment instance and click Metric Scraping in the Actions column. The Metric Scraping tab appears.

  3. On the Metric Scraping tab, click Default Service Discovery.

  1. On the Default Service Discovery page, click Enabled to enable the default service discovery feature.

    image

    After the feature is enabled, Managed Service for Prometheus collects the metrics exposed by all pods with the following annotations in the cluster:

    annotations:
      prometheus.io/path: /metrics # The HTTP path where you want to expose the metrics. 
      prometheus.io/port: "xxxx" # The port on which you want to expose the metrics. 
      prometheus.io/scrape: "true" # Specify whether to capture the metrics.
  2. On the Metric Scraping tab, view the list of pods that are found by the default service discovery feature.

Related operation

On the Default Service Discovery page, click Feature Disabled to disable the default service discovery feature. After the feature is disabled, Managed Service for Prometheus no longer collects metrics that are exposed by pods with the prometheus.io annotations.