Monitor TiDB databases with Prometheus

更新时间:
复制 MD 格式

Managed Service for Prometheus collects TiDB, PD, TiKV, and TiConsole metrics and provides pre-built dashboards and alert rules — no self-managed Prometheus, Grafana, or Alertmanager stack required.

Prerequisites

Ensure that you have:

  • A VPC-connected Managed Service for Prometheus instance. Prometheus for ECS

  • A running TiDB cluster deployed on ECS instances within the VPC

Why use Managed Service for Prometheus

Self-managed Prometheus for TiDB introduces operational challenges:

  • Repeated deployments across VPCs. Each isolated VPC requires its own Prometheus, Grafana, and Alertmanager installation.

  • No native ECS service discovery. Open source Prometheus uses static_configs or third-party registries. ECS-aware discovery requires custom Go code that calls the Alibaba Cloud ECS POP API, adding development effort and complicating upgrades.

  • Limited dashboards and alert rules. Open source Grafana dashboards for TiDB show raw metrics without operational best-practice analysis, and no pre-built alert rule templates are available.

The following table compares both approaches.

Capability Self-managed Prometheus Managed Service for Prometheus
Deployment Deploy Prometheus, Grafana, and Alertmanager on ECS in each VPC Fully managed with built-in Grafana and alerting
Availability and scalability Limited by self-managed infrastructure High availability, high performance, and large data capacity
Service discovery static_configs or third-party registries; no ECS integration Built-in aliyun_sd_configs with ECS tag-based matching, consistent with labelSelector in Kubernetes
Dashboards Basic open source dashboards Specialized TiDB dashboard templates built on monitoring best practices
Alert rules Must research and configure rules manually 30+ pre-configured alert rules with GUI-based customization

Step 1: Add the TiDB integration

  1. Log in to the ARMS console.

  2. In the left navigation pane, click Integration Center.

  3. In the Database section, click TIDB, then follow the on-screen instructions.

  4. Select the environment type: Kubernetes Environment or ECS (VPC).

  5. Select the target Kubernetes cluster or VPC.

  6. In the Configuration Information section, configure the following parameters and click OK.

    Parameter Description
    Access Name A custom name for this integration
    TIDB Cluster Name The TiDB cluster name. Use a unique name per integration to avoid metric conflicts and dashboard errors
    Namespace A custom namespace
    PD Server Container Name The PD container name. Separate multiple names with a vertical bar (pd|pd1) for OR matching
    PD Metrics Port Port that exposes PD metrics
    PD Metrics Collection Path HTTP scrape path for PD metrics, typically /metrics
    TiDB Server Container Name The TiDB server container name
    TiDB Metrics Port Port that exposes TiDB metrics
    TiDB Metrics Collection Path HTTP scrape path for TiDB metrics, typically /metrics
    TiKV Server Container Name The TiKV server container name
    TiKV Metrics Port Port that exposes TiKV metrics
    TiKV Metrics Collection Path HTTP scrape path for TiKV metrics, typically /metrics
    Metric collection Interval (units/second) Scrape interval in seconds. Default: 30
  7. After the integration completes, click the Collect Metrics tab to confirm that metrics are being collected.

The integration appears on the Integration Management page. This page includes the Integrated Environments, Integrated Addons, and Query Dashboards tabs for checking targets, metrics, dashboards, and alerts.

Step 2: View TiDB dashboards

Managed Service for Prometheus includes 20+ built-in Grafana dashboards for TiDB components. No separate Grafana installation is required.

To access the dashboards:

  1. Go to the Integration Management page and select your TiDB cluster.

  2. Click the Dashboards tab.

  3. Click a dashboard link to open it in Alibaba Cloud Grafana.

Step 3: Configure alert rules

Managed Service for Prometheus automatically creates 30+ alert rules for TiDB. To review and enable them:

  1. Go to the Integration Management page and select your TiDB cluster.

  2. Click the Alert Rules tab.

  3. Review the pre-configured rules, adjust thresholds based on your workload patterns, and enable them.

To add custom rules, Create a Prometheus alert rule.

What's next

  • Explore the built-in TiDB dashboards to understand cluster health, query performance, and storage metrics

  • Fine-tune alert thresholds based on your workload patterns

  • Use ECS tags with aliyun_sd_configs to dynamically manage scrape targets as your TiDB cluster scales