On the Service Discovery tab, you can view the default ServiceMonitor that is provided by Prometheus Service of Application Real-Time Monitoring Service (ARMS). You can also create a ServiceMonitor to configure collection rules for Prometheus Service. You can create a ServiceMonitor if you want to monitor the business data of applications in a Kubernetes cluster, such as order information.

Manage the default ServiceMonitor

Prometheus Service offers the build-in service discovery feature by providing the default ServiceMonitor. The default ServiceMonitor is automatically enabled when you add a Kubernetes cluster to Prometheus Service. The default ServiceMonitor collects metrics of pods in all namespaces of the Kubernetes cluster. If a pod contains the following annotations, the default ServiceMonitor collects metrics of the pod and charges you fees:
  • prometheus.io/path: /metrics
  • prometheus.io/port: "9104"
  • prometheus.io/scrape: "true"
Default ServiceMonitor

View the default ServiceMonitor

  1. Log on to the ARMS console.
  2. In the left-side navigation pane, click Prometheus Monitoring.
  3. In the top navigation bar, select the region in which your Kubernetes cluster resides.
  4. On the Prometheus Monitoring page, click the name of the Kubernetes cluster.
  5. In the left-side navigation pane, click Settings.
  6. On the right side of the page, click the Service Discovery tab, and then click the Default Service Discovery tab.

More operations

On the Default Service Discovery tab, you can perform the following operations:
  • Click Details in the Actions column to view the YAML file of the default ServiceMonitor.
  • Turn on or off the switch in the Actions column to enable or disable the default ServiceMonitor.

Manage custom ServiceMonitors

You can manually create ServiceMonitors to collect metrics based on your configurations. You are charged fees when you use ServiceMonitors to collect metrics.

Create a ServiceMonitor

  1. On the Service Discovery tab, click the ServiceMonitor tab. Then, click Add ServiceMonitor.
  2. In the Add ServiceMonitor dialog box, enter the configuration of the ServiceMonitor and click OK.
    Sample configuration:
    apiVersion: monitoring.coreos.com/v1
    kind: ServiceMonitor
    metadata:
      # Enter a unique name. 
      name: tomcat-demo
      # Enter a namespace. 
      namespace: default
    spec:
      endpoints:
      - interval: 30s
        # Enter the value of the Name field for Port of Prometheus Exporter in the service.yaml file. 
        port: tomcat-monitor
        # Enter the value of the Path field for Prometheus Exporter. 
        path: /metrics
      namespaceSelector:
        any: true
        # The namespace of the NGINX demo application. 
      selector:
        matchLabels:
          # Enter the value of the Label field in the service.yaml file to find the service.yaml file. 
          app: tomcat
    The ServiceMonitor appears on the ServiceMonitor tab. Create a ServiceMonitor

More operations

On the ServiceMonitor tab, you can perform the following operations:
  • Turn on or off the switch in the Actions column of a ServiceMonitor to enable or disable the ServiceMonitor. You can also click Disable all to disable all the ServiceMonitors that have been created.
  • Click Delete in the Actions column of a ServiceMonitor to delete the ServiceMonitor.