All Products
Search
Document Center

Managed Service for Prometheus:Use ServiceMonitor to collect metrics

Last Updated:Aug 14, 2024

By configuring ServiceMonitor, you can collect metrics exposed at the specified pod in a Container Service for Kubernetes (ACK) cluster. This way, you can use Alibaba Cloud Managed Service for Prometheus to monitor the ACK cluster in a flexible, automated, and efficient manner.

Limits

You can configure ServiceMonitor to collect metrics only of ACK clusters.

Billing

The ServiceMonitor feature incurs fees. For more information, see Billing.

Prerequisites

Procedure

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

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

  3. 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.

  4. On the Metric Scraping tab, click Service Monitor.

Enable the ServiceMonitor feature

On the Service Monitor tab, click Enabled. Then, you can view all ServiceMonitor configurations and details in the ACK cluster. ARMS captures metrics based on the path of the pod at the specified time interval.

Note

ServiceMonitor is disabled by default.

image

Manage ServiceMonitor configurations

Add a ServiceMonitor configuration

On the ServiceMonitor tab, click Create. In the Add ServiceMonitor Configuration panel, specify the ServiceMonitor configuration and click Create.

Quick Start

Specify the Namespace, Service, Port, Metric Path, and Collection Interval parameters, and then click Check. If the parameter values are valid, you can click Create to create a ServiceMonitor configuration.

image

YAML

Specify a YAML file to create a ServiceMonitor configuration. Click Check to check whether the configuration is valid. Then, click Create.

image

Modify a ServiceMonitor configuration

On the ServiceMonitor tab, find the ServiceMonitor configuration and click Edit in the Actions column. In the Edit Service Monitor Configuration panel, modify the YAML file.

Delete a ServiceMonitor configuration

On the ServiceMonitor tab, find the ServiceMonitor configuration and click Delete in the Actions column.

Disable a ServiceMonitor configuration

On the ServiceMonitor tab, find the ServiceMonitor configuration and click Disable in the Actions column. After the configuration is disabled, it loses effectiveness.

Disable the ServiceMonitor feature

On the Service Monitor tab, click Feature Disabled. After the ServiceMonitor feature is disabled, Prometheus does not detect or collect metrics exposed at the pod, though targets that are being collected continue to be collected.