All Products
Search
Document Center

:Synchronize the ServiceMonitor and PodMonitor in a cluster

Last Updated:Jan 31, 2024

If you synchronize the ServiceMonitor and PodMonitor in a cluster, you can prevent the repeated collection of metric data, and unnecessary resource consumption and costs.

Prerequisites

  • The Helm version of your Prometheus instance is upgraded to V1.1.5 or later. For more information, see Upgrade the component version.

  • Optional. If you want Managed Service for Prometheus to discover the ServiceMonitor or PodMonitor that is created in your cluster by running commands, you must add the following sample annotations when you create the ServiceMonitor or PodMonitor.

    annotations:
      arms.prometheus.io/discovery: 'true' // To enable Alibaba Cloud Prometheus Service to discover the ServiceMonitor or PodMonitor, set the value to true. Otherwise, set the value to false.

Background information

Managed Service for Prometheus allows you to discover the ServiceMonitor and PodMonitor in a cluster and collects data. If you have created a ServiceMonitor or PodMonitor in your cluster by running commands, or you have installed the ServiceMonitor or PodMonitor provided by open source Prometheus in your cluster, the collection tasks may conflict with the default collection tasks of Managed Service for Prometheus. This may cause unnecessary resource consumption and incur fees.

To prevent unnecessary costs and resource consumption, Managed Service for Prometheus provides the following switches: "Automatically synchronize ServiceMonitor in a cluster" and "Automatically synchronize PodMonitor in a cluster". You can specify whether to synchronize the ServiceMonitor or PodMonitor by turning on or off the corresponding switch. If you turn on the switch, Managed Service for Prometheus discovers the ServiceMonitor or PodMonitor that is created in the cluster. If you turn off the switch, Managed Service for Prometheus discovers only the ServiceMonitor or PodMonitor that is created in the Managed Service for Prometheus console.

Procedure

This example shows how to synchronize the ServiceMonitor in a cluster. You can also follow the procedure to synchronize the PodMonitor in a cluster.

  1. Log on to the ARMS console.
  2. In the left-side navigation pane, choose Prometheus Service > Prometheus Instances.
  3. Click the name of the Prometheus instance to which you want to connect.
  4. In the left-side navigation pane, click Service Discovery.

  5. On the Service Discovery tab, click the Configurations tab. Then, click the ServiceMonitor tab. On this tab, turn on Automatically synchronize ServiceMonitor in a cluster.

    Note
    • If you need to synchronize the PodMonitor in a cluster, you can click the PodMonitor tab and turn on Automatically synchronize PodMonitor in a cluster.

    • When you edit the ServiceMonitor or PodMonitor, do not delete the annotations field. Otherwise, data collection will be affected.

References

  • After ServiceMonitor and PodMonitor are synchronized in the cluster, you may need to view the metrics collected by service discovery. For more information, see Configure metrics.

  • After ServiceMonitor and PodMonitor are synchronized in the cluster, you may be charged for the metrics that are collected. For more information, see Billing (new) and Billing (old).

  • For information about how to manually configure ServiceMonitor or PodMonitor, see Manage service discoveries.