Prometheus is an open source monitoring tool for cloud native applications. This topic describes how to deploy the Prometheus monitoring system by using Alibaba Cloud Container Service for Kubernetes.

Prerequisites

Background information

A monitoring system monitors the following two types of objects:
  • Resource, namely, the resource usage of a node or application. The monitoring system of Container Service for Kubernetes monitors node resource usage, cluster resource usage, and pod resource usage.
  • Application, namely, internal metrics of an application. For example, The monitoring system collects statistics regarding the number of online users that use an application in real time, and performs service-level monitoring and alarming for the application by exposing ports.
The following are the objects monitored in a Kubernetes cluster:
  • System components, which are built-in components of the Kubernetes cluster, such as apiserver, controller-manager, and etcd.
  • Static resource entities, which include node resource status and kernel events.
  • Dynamic resource entities, which are abstract workload entities of Kubernetes, such as deployment, DaemonSet, and pods.
  • Customized application objects, which includes the data and metrics that require customization within an application.

To monitor system components and static resource entities, you need to specify monitoring methods for them in the configuration file.

To monitor dynamic resource entities, we recommend that you deploy the Prometheus monitoring system.

Procedure

  1. Deploy Prometheus monitoring system
    1. Log on to the Container Service console.
    2. In the left-side navigation pane under Container Service-Kubernetes, choose Marketplace > App Catalog. Then, click ack-prometheus-operator.
    3. In the Deploy area, select the target cluster. Then, click Create.
      Prometheus-operator
      Verify the result
      1. Run the following command to map the Prometheus that is deployed to the cluster to the local port 9090.
        kubectl port-forward svc/ack-prometheus-operator-prometheus 9090:9090 -n monitoring
      2. To view Prometheus, accesslocalhost:9090 in a browser.
        Note By default, Prometheus cannot be accessed through the Internet. You must use your local proxy to access it.
      3. Select Targets under the Status menu to view all collection tasks.

        If the status of all tasks is UP, all collection tasks are running properly.

  2. View and display data aggregation.
    1. Run the following command to may the Grafana that is deployed to the cluster to the local port 3000.
      kubectl -n monitoring port-forward svc/ack-prometheus-operator-grafana 3000:80
    2. Access localhost:3000 in your browser and then select a dashboard to view data aggregation.
      Note The default user name and password are both admin.


  3. View alerting rules and set alert silencing.
    • View alerting rules
      Access localhost:9090 in your browser and click the Alerts menu to view the current alerting rules.
      • Red: indicates that an alert is triggered.
      • Green: indicates the normal status.


    • Set alert silencing
      Run the following command, openlocalhost:9093 in your browser, and select Silenced to set alert silencing:
      kubectl --namespace monitoring port-forward svc/alertmanager-operated 9093