Enable Shards for TidbMonitor

This document describes how to use shards for TidbMonitor.

Shards

TidbMonitor collects monitoring data for a single TiDB cluster or multiple TiDB clusters. When the amount of monitoring data is large, the computing capacity of one TidbMonitor might hit a bottleneck. In this case, it is recommended to use shards of Prometheus Modulus. This feature performs hashmod on __address__ to divide the monitoring data of multiple targets (Targets) into multiple TidbMonitor Pods.

To use shards for TidbMonitor, you need a data aggregation plan. The Thanos method is recommended.

Enable shards

To enable shards for TidbMonitor, you need to specify the shards field. For example:

  1. apiVersion: pingcap.com/v1alpha1
  2. kind: TidbMonitor
  3. metadata:
  4. name: monitor
  5. spec:
  6. replicas: 1
  7. shards: 2
  8. clusters:
  9. - name: basic
  10. prometheus:
  11. baseImage: prom/prometheus
  12. version: v2.27.1
  13. initializer:
  14. baseImage: pingcap/tidb-monitor-initializer
  15. version: v5.2.1
  16. reloader:
  17. baseImage: pingcap/tidb-monitor-reloader
  18. version: v1.0.1
  19. prometheusReloader:
  20. baseImage: quay.io/prometheus-operator/prometheus-config-reloader
  21. version: v0.49.0
  22. imagePullPolicy: IfNotPresent

Enable Shards for TidbMonitor - 图1Note

  • The number of Pods corresponding to TidbMonitor is the product of replicas and shards. For example, when replicas is 1 and shards is 2, TiDB Operator creates 2 TidbMonitor Pods.
  • After shards is changed, Targets are reallocated. However, the monitoring data already stored on the Pods is not reallocated.

For details on the configuration, refer to shards example.