All Products
Search
Document Center

Deploy Prometheus on Kubernetes clusters

Last Updated: May 19, 2022

This topic describes how to deploy Prometheus on Kubernetes clusters.

Background information

Kubernetes is an open source system that automates the processes to deploy containerized applications. Kubernetes can also help you expand and manage containerized applications. For more information about Kubernetes, see Kubernetes documentation. This topic describes how to deploy Prometheus on a Container Service for Kubernetes (ACK) cluster and store the monitoring data that is collected by Prometheus to a Time Series Database (TSDB) database.

Prometheus is an open source monitoring tool for cloud native applications. Prometheus identifies the servers to monitor based on service discovery or static configurations. Prometheus monitors the following objects in Kubernetes:

  • System components that are built in Kubernetes clusters, such as kube-apiserver, kube-controller-manager, and etcd.

  • Static resource entities, such as resource statuses of nodes and kernel events.

  • Dynamic resource entities that are the entities of abstract workloads in Kubernetes, such as deployments, DaemonSets, and pods.

  • Custom objects in applications, such as the custom data and metrics in applications.

To monitor system components and static resource entities, specify the monitoring methods in the configuration files. To monitor dynamic resource entities for a Kubernetes cluster, you can deploy Prometheus on the Kubernetes cluster.

Procedure

  1. Deploy Prometheus on a Kubernetes cluster to monitor data.

    You can use Prometheus Operator to deploy Prometheus on a Kubernetes cluster. For more information, see Use the open source tool Prometheus to monitor a Kubernetes cluster.

  2. Modify the configuration of Prometheus.

    Modify the file prometheus-prometheus.yaml. In the spec object, create the configuration items remoteWrite and remoteRead for Prometheus. Prometheus Operator uses the camelCase naming convention to configure remote settings for Prometheus.

    In this example, the instance type of the TSDB instance is 3xlarge. You can configure the settings based on the following code. You can modify the configuration item queueConfig based on your business requirements.

    spec:
      remoteWrite:
      - url: "http://ts-xxxxxxxxxxxx.hitsdb.rds.aliyuncs.com:3242/api/prom_write"
        queueConfig:
          capacity: 10000
          maxShards: 6
          maxSamplesPerSend: 500
      remoteRead:
      - url: "http://ts-xxxxxxxxxxxx.hitsdb.rds.aliyuncs.com:3242/api/prom_read"
        readRecent: true

    To obtain more configuration items in prometheus-prometheus.yaml, go to the GitHub repository of prometheus-operator. For more information, see GitHub repository.

  3. Update the configuration.

    Run the following command to update the modified configuration:

    kubectl apply -f manifests/prometheus-prometheus.yaml