Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/pingcap/tidb/llms.txt

Use this file to discover all available pages before exploring further.

TiDB exposes runtime metrics via a Prometheus-compatible HTTP endpoint on port 10080. These metrics can be scraped by Prometheus and visualized in Grafana. TiDB also ships with a built-in dashboard via PD for visual cluster monitoring.

HTTP Status API

The TiDB HTTP Status API is available on port 10080 by default. Use it to query live server state and metrics.
EndpointDescription
GET /statusServer status: connections, version, git hash
GET /metricsAll Prometheus metrics
GET /regions/metaMetadata for all regions
GET /regions/hotHot read/write regions by table
GET /schemaSchema information for all databases
Example: check server status
curl http://127.0.0.1:10080/status
{
    "connections": 0,
    "git_hash": "f572e33854e1c0f942f031e9656d0004f99995c6",
    "version": "5.7.25-TiDB-v2.1.0-rc.3-355-gf572e3385-dirty",
    "status": {
        "init_stats_percentage": 100
    }
}
Example: scrape Prometheus metrics
curl http://127.0.0.1:10080/metrics

Key metrics to watch

These metrics are the most useful starting point for diagnosing performance issues and setting up alerts.
Metric nameTypeWhat it measures
tidb_server_query_totalCounterTotal queries, labeled by result type
tidb_server_handle_query_duration_secondsHistogramQuery latency distribution
tidb_server_connectionsGaugeCurrent open client connections
process_resident_memory_bytesGaugeTiDB server memory usage
tidb_executor_statement_totalCounterStatements executed, by type
tidb_tikvclient_txn_cmd_duration_secondsHistogramTiKV round-trip latency

Grafana integration

TiDB ships Grafana dashboard definitions in pkg/metrics/grafana/. A standard TiUP or TiDB Operator deployment provisions Grafana automatically.
1

Deploy Grafana with TiUP

TiUP includes a Grafana component. It is deployed alongside Prometheus when you run tiup cluster deploy.
tiup cluster display <cluster-name>
The Grafana URL appears in the output under Dashboard.
2

Import dashboards manually

If you are running a custom deployment, import the dashboard JSON files from the TiDB source repository:
pkg/metrics/grafana/
pkg/metrics/nextgengrafana/
In Grafana, go to Dashboards > Import and upload the JSON file.
3

Configure Prometheus scrape target

Add the TiDB status endpoint to your Prometheus configuration:
scrape_configs:
  - job_name: tidb
    static_configs:
      - targets: ["127.0.0.1:10080"]

TiDB Dashboard

TiDB Dashboard is built into PD and provides a visual interface for cluster health, slow query analysis, and diagnostics. Access it at http://<pd-host>:2379/dashboard. Default credentials are the root MySQL user with no password (update this in production). Key features:
  • Cluster overview: topology, node status, alerts
  • Slow queries: filterable slow query log with execution plans
  • Key Visualizer: heatmap of region read/write traffic
  • Diagnostics: automated cluster health report

Alert rules

Configure the following alert thresholds in Prometheus Alertmanager:
groups:
  - name: tidb
    rules:
      - alert: TiDBHighQueryLatency
        expr: histogram_quantile(0.99, rate(tidb_server_handle_query_duration_seconds_bucket[5m])) > 1
        for: 5m
        annotations:
          summary: "P99 query latency exceeds 1s"

      - alert: TiDBHighConnectionCount
        expr: tidb_server_connections > 5000
        for: 2m
        annotations:
          summary: "Connection count is high"

      - alert: TiDBHighMemoryUsage
        expr: process_resident_memory_bytes{job="tidb"} > 8e9
        for: 5m
        annotations:
          summary: "TiDB memory usage exceeds 8 GB"

Build docs developers (and LLMs) love