Enable synchronization for ServiceMonitor and PodMonitor in your cluster to prevent duplicate metric collection tasks, avoiding unnecessary resource consumption and additional costs.
Prerequisites
The Helm chart for your Prometheus instance must be v1.1.5 or later. For more information, see Upgrade the component version.
(Optional) If you want ServiceMonitors or PodMonitors that you create by using cluster commands to be discovered by Managed Service for Prometheus, you need to add an annotation as shown in the following example during creation.
annotations: arms.prometheus.io/discovery: 'true' // Set to 'true' for discovery, 'false' to ignore.
Background
Alibaba Cloud Managed Service for Prometheus allows you to manually configure service discovery to collect metrics from the ServiceMonitors and PodMonitors in your cluster. If you have created ServiceMonitors or PodMonitors in your cluster by using the command line, or if your cluster has ServiceMonitors or PodMonitors that are included with an open-source Prometheus installation, these collection tasks may overlap with the service discovery tasks that you manually configure in Alibaba Cloud Managed Service for Prometheus. This duplication leads to unnecessary resource consumption and additional charges, which increases your usage costs.
To avoid unnecessary costs and resource consumption, Managed Service for Prometheus provides a switch for one-click synchronization of ServiceMonitor and PodMonitor resources in a cluster. You can decide whether to synchronize ServiceMonitor or PodMonitor resources based on your requirements. If you turn on the synchronization switch, Managed Service for Prometheus discovers the ServiceMonitor or PodMonitor resources that you create in the cluster and collects the related metrics. Otherwise, Managed Service for Prometheus discovers only the ServiceMonitor or PodMonitor resources that are created through the Managed Service for Prometheus console.
Procedure
The steps to synchronize ServiceMonitor and PodMonitor resources are similar. This topic uses ServiceMonitor as an example.
-
Log on to the ARMS console.
-
In the left navigation pane, choose .
-
Click the name of the Managed Service for Prometheus instance.
In the navigation pane on the left, click Service Discovery.
On the Service Discovery page, click the Configurations tab, and then click the ServiceMonitor tab. Turn on the Automatically synchronize ServiceMonitor switch.
NoteTo synchronize PodMonitor resources, click the PodMonitor tab and turn on the Automatically synchronize PodMonitor switch.
When editing a ServiceMonitor or PodMonitor, do not delete the annotations field. Deleting this field can disrupt data collection.
Related topics
After you enable synchronization, you may want to view the metrics collected through service discovery. For more information, see Configure metrics to be dropped.
Enabling synchronization may incur charges for collected metrics. For more information, see Billing (new) and Billing (old).
If you still need to manually configure service discovery for ServiceMonitor or PodMonitor, see Manage service discoveries for Kubernetes clusters.