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.
ImportantIf 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
Log on to the ACK console.
On the Clusters page, click the name of the cluster that you want to manage and choose
in the left-side navigation pane.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.
Click Update.
Step 2: Enable default service discovery
In the left-side navigation pane, click Integration Management.
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.
On the Metric Scraping tab, click Default Service Discovery.
On the Default Service Discovery page, click Enabled to enable the default service discovery feature.
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.
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.