You can edit the prometheus.yaml file or add ServiceMonitor to configure a data collection rule. Then, Prometheus Monitoring can use the rule to monitor an application.

Prerequisites

The Prometheus agent is installed for an application. For more information, see Create a Prometheus instance to monitor an ACK cluster.

Procedure

  1. Log on to the ARMS console .
  2. In the left-side navigation pane, choose Prometheus Monitoring > Prometheus Instances.
  3. In the upper-left corner of the Prometheus Monitoring page, select the region where your Container Service for Kubernetes (ACK) clusters reside. Find the cluster that you want to manage and click Settings in the Actions column.
  4. Configure data collection rules for Prometheus Service to monitor the application in the following scenarios:
    • To monitor the business data of the application that is deployed to the ACK cluster, such as order information, you can perform the following operations:
      1. In the left-side navigation pane, click Service Discovery. Then, click the Configure tab.
      2. On the Configure tab, click the ServiceMonitor tab. Then, click Add ServiceMonitor.
      3. In the Add ServiceMonitor dialog box, enter the following code and click OK:
        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 of Port of Prometheus Exporter in the service.yaml file.
            port: tomcat-monitor
            # Enter the value of the Path field of Prometheus Exporter.
            path: /metrics
          namespaceSelector:
            any: true
            # The namespace of the demo.
          selector:
            matchLabels:
              # Enter the value of the Label field in the service.yaml file to find the service.yaml file.
              app: tomcat

        The configured service discovery task is displayed on the ServiceMonitor tab.

        service discovery
    • To monitor business data outside the ACK cluster, such as the number of Redis connections, you can perform the following operations:
      1. On the Settings page, click the Settings tab.
      2. On the Settings tab, enter the following code in the Prometheus.yaml code editor and click Save:
        global:
          scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
          evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
        scrape_configs:
          - job_name: 'prometheus'
            static_configs:
            - targets: ['localhost:9090']