
- name: 总体性能概览:QPS:total
  stats: enable
  chartType: line
  unit: "1"
  metricsType: "Counter"
  expr: 'sum(rate(tidb_executor_statement_total[1m]))'
  component: TiDB
  chartTitle: 'TiDB-QPS-total'
  dashboard:
    - title: 'Overview-TiDB-QPS'

- name: QPS:by_instance
  stats: enable
  unit: "1"
  metricsType: "Counter"
  expr: 'sum(rate(tidb_executor_statement_total[1m])) by (instance)'
  component: TiDB
  chartTitle: 'TiDB-QPS-by_instance'
  dashboard:
    - title: 'Overview-TiDB-QPS'

- name: QPS:by_type
  stats: enable
  unit: "1"
  metricsType: "Counter"
  expr: 'sum(rate(tidb_executor_statement_total[1m])) by (type)'
  component: TiDB
  chartTitle: 'TiDB-QPS-by_type'
  dashboard:
    - title: 'Overview-TiDB-QPS'

- name: QPS:by_type
  stats: enable
  chartType: bar
  unit: "1"
  metricsType: "Counter"
  expr: 'sum(rate(tidb_executor_statement_total[1m])) by (type)'
  component: TiDB
  chartTitle: 'TiDB-QPS2-by_type'
  dashboard:
    - title: 'Overview-TiDB-QPS'

- name: TPS:by_type
  stats: enable
  unit: "1"
  metricsType: "Counter"
  expr: 'sum(rate(tidb_session_transaction_duration_seconds_count[1m])) by (type)'
  component: TiDB
  chartTitle: 'TPS-by_type'
  dashboard:
    - title: 'Overview-TiDB-Transaction OPS'

- name: TPS:by_type&txn_mode
  stats: enable
  unit: "1"
  metricsType: "Counter"
  expr: 'sum(rate(tidb_session_transaction_duration_seconds_count[1m])) by (type,txn_mode)'
  component: TiDB
  chartTitle: 'TPS-by_type&txn_mode'
  dashboard:
    - title: 'Overview-TiDB-Transaction OPS'

- name: Query Duration:total
  stats: enable
  unit: "ms"
  metricsType: "Histogram"
  expr: 'histogram_quantile(0.99, sum(rate(tidb_server_handle_query_duration_seconds_bucket[1m])) by(le))'
  component: TiDB
  chartTitle: 'TiDB-Duration-total'
  dashboard:
    - title: 'Overview-TiDB-Duration'

- name: Query Duration:by_instance
  stats: disable
  unit: "ms"
  metricsType: "Histogram"
  expr: 'histogram_quantile(0.99, sum(rate(tidb_server_handle_query_duration_seconds_bucket[1m])) by(instance, le))'
  component: TiDB
  chartTitle: 'TiDB-Duration-by_instance'
  dashboard:
    - title: 'Overview-TiDB-Duration'

- name: Query Duration:by_sql_type
  stats: disable
  unit: "ms"
  metricsType: "Histogram"
  expr: 'histogram_quantile(0.99, sum(rate(tidb_server_handle_query_duration_seconds_bucket[1m])) by(sql_type, le))'
  component: TiDB
  chartTitle: 'TiDB-Duration-by_sql_type'
  dashboard:
    - title: 'Overview-TiDB-Duration'

- name: Transaction Duration:total
  stats: enable
  unit: "ms"
  metricsType: "Histogram"
  expr: 'histogram_quantile(0.99, sum(rate(tidb_session_transaction_duration_seconds_bucket[1m])) by(le))'
  component: TiDB
  chartTitle: 'Transaction-Duration-total'
  dashboard:
    - title: 'Overview-TiDB-Transaction Duration'

- name: Transaction Duration:by_instance
  stats: disable
  unit: "ms"
  metricsType: "Histogram"
  expr: 'histogram_quantile(0.99, sum(rate(tidb_session_transaction_duration_seconds_bucket[1m])) by(instance, le))'
  component: TiDB
  chartTitle: 'Transaction-Duration-by_instance'
  dashboard:
    - title: 'Overview-TiDB-Transaction Duration'

- name: Transaction Duration:by_type
  stats: enable
  unit: "ms"
  metricsType: "Histogram"
  expr: 'histogram_quantile(0.99, sum(rate(tidb_session_transaction_duration_seconds_bucket[1m])) by(type, le))'
  component: TiDB
  chartTitle: 'Transaction-Duration-by_type'
  dashboard:
    - title: 'Overview-TiDB-Transaction Duration'

- name: Database time:by_sql_type
  stats: enable
  chartType: bar
  unit: "ms"
  metricsType: "Counter"
  expr: 'sum(rate(tidb_server_handle_query_duration_seconds_sum{sql_type!="internal"}[1m])) by(sql_type)'
  component: Database
  chartTitle: 'Database time-by_sql_type'
  dashboard:
    - title: 'Performance-Overview-Database time'

- name: Workload-read-RPC:total
  stats: enable
  unit: "1"
  metricsType: "Counter"
  expr: 'sum(rate(tikv_grpc_msg_duration_seconds_count{type=~"kv_get|kv_scan|kv_batch_get|kv_batch_get_command|coprocessor"}[1m]))'
  component: TiKV
  chartTitle: 'Workload-read-RPC-total'
  dashboard:
    - title: 'TiKV-FastTune-Summary-Imbalanced read'

- name: Workload-write-RPC:total
  stats: enable
  unit: "1"
  metricsType: "Counter"
  expr: 'sum(rate(tikv_grpc_msg_duration_seconds_count{type=~"kv_prewrite|kv_commit|kv_pessimistic_lock"}[1m]))'
  component: TiKV
  chartTitle: 'Workload-write-RPC-total'
  dashboard:
    - title: 'TiKV-FastTune-Summary-Imbalanced write'

- name: OS资源检查:TiDB_CPU:by_instance
  stats: enable
  unit: "%"
  metricsType: "Counter"
  expr: 'rate(process_cpu_seconds_total{job="tidb"}[1m])'
  component: TiDB
  chartTitle: 'TiDB-CPU-Usage-by_instance'
  dashboard:
    - title: 'TiDB-Server-CPU Usage'

- name: TiKV_CPU:by_instance
  stats: enable
  unit: "%"
  metricsType: "Counter"
  expr: 'rate(process_cpu_seconds_total{job="tikv"}[1m])'
  component: TiKV
  chartTitle: 'TiKV-CPU-Usage-by_instance'
  dashboard:
    - title: 'TiKV Summary-Cluster-CPU'

- name: PD_CPU:by_instance
  stats: enable
  unit: "%"
  metricsType: "Counter"
  expr: 'rate(process_cpu_seconds_total{job="pd"}[1m])'
  component: PD
  chartTitle: 'PD-CPU-Usage-by_instance'
  dashboard:
    - title: 'PD-Cluster-CPU Usage'

- name: TiDB_Memory:by_instance
  unit: "Bytes"
  metricsType: "Gauge"
  expr: 'max(process_resident_memory_bytes{job="tidb"}) by(instance)'
  component: TiDB
  chartTitle: 'TiDB-Memory-process-by_instance'
  dashboard:
    - title: 'TiDB-Server-Memory Usage'

- name: TiDB_Memory:by_instance
  unit: "Bytes"
  metricsType: "Gauge"
  expr: 'max(go_memstats_heap_inuse_bytes{job="tidb"}) by(instance)'
  component: TiDB
  chartTitle: 'TiDB-Memory-inuse-by_instance'
  dashboard:
    - title: 'TiDB-Server-Memory Usage'

- name: PD_Memory:by_instance
  unit: "Bytes"
  metricsType: "Gauge"
  expr: 'max(process_resident_memory_bytes{job="pd"}) by(instance)'
  component: PD
  chartTitle: 'PD-Memory-by_instance'
  dashboard:
    - title: 'PD-Cluster-Memory Usage'

- name: PD_Memory:by_instance
  unit: "Bytes"
  metricsType: "Gauge"
  expr: 'max(go_memstats_heap_inuse_bytes{job="pd"}) by(instance)'
  component: PD
  chartTitle: 'PD-Memory-inuse-by_instance'
  dashboard:
    - title: 'PD-Cluster-Memory Usage'


- name: TiKV_Memory:by_instance
  unit: "Bytes"
  metricsType: "Gauge"
  expr: 'max(process_resident_memory_bytes{job="tikv"}) by(instance)'
  component: TiKV
  chartTitle: 'TiKV-Memory-by_instance'
  dashboard:
    - title: 'TiKV Summary-Cluster-Memory'

- name: TiKV_IO:by_instance&device
  stats: enable
  unit: "%"
  metricsType: "Counter"
  expr: 'sum(rate(node_disk_io_time_seconds_total[1m])) by (instance,device)'
  component: TiKV
  chartTitle: 'TiKV-IO-utilization-by_instance&device'
  dashboard:
    - title: 'TiKV Summary-Cluster-IO utilization'

- name: TiKV_IO:by_instance&type
  stats: enable
  unit: "Bytes"
  metricsType: "Counter"
  expr: 'sum(rate(tikv_engine_flow_bytes{type=~"wal_file_bytes|bytes_read|iter_bytes_read"}[1m])) by (instance,type)'
  component: TiKV
  chartTitle: 'TiKV-IO-MBps-by_instance&type'
  dashboard:
    - title: 'TiKV Summary-Cluster-MBps'

- name: 各组件健康检查:PD TSO Wait Duration:total
  stats: enable
  unit: "ms"
  metricsType: "Histogram"
  expr: 'histogram_quantile(0.99, sum(rate(pd_client_cmd_handle_cmds_duration_seconds_bucket{type="wait"}[1m])) by(le))'
  component: TiDB
  chartTitle: 'PD TSO Wait Duration-total'
  dashboard:
    - title: 'TiDB-PD Cline-PD TSO Wait Duration'

- name: PD TSO RPC Duration:total
  stats: enable
  unit: "ms"
  metricsType: "Histogram"
  expr: 'histogram_quantile(0.99, sum(rate(pd_client_request_handle_requests_duration_seconds_bucket{type="tso"}[1m])) by(le))'
  component: TiDB
  chartTitle: 'PD TSO RPC Duration-total'
  dashboard:
    - title: 'TiDB-PD Cline-PD TSO RPC Duration'

- name: TiKV_Leader:by_instance
  unit: "1"
  metricsType: "Gauge"
  expr: 'max(tikv_raftstore_region_count{type="leader"}) by(instance)'
  component: TiKV
  chartTitle: 'TiKV-Leader-by_instance'
  dashboard:
    - title: 'TiKV Summary-Cluster-Leader'


- name: TiKV_Region:by_instance
  unit: "1"
  metricsType: "Gauge"
  expr: 'max(tikv_raftstore_region_count{type="region"}) by(instance)'
  component: TiKV
  chartTitle: 'TiKV-Region-by_instance-by_instance'
  dashboard:
    - title: 'TiKV Summary-Cluster-Region'

- name: TiDB Get Token Duration:total
  stats: enable
  unit: "1"
  metricsType: "Histogram"
  expr: 'histogram_quantile(0.99, sum(rate(tidb_server_get_token_duration_seconds_bucket[1m])) by(le))'
  component: TiDB
  chartTitle: 'TiDB Get Token Duration-total'
  dashboard:
    - title: 'TiDB-Server-Get Token Duration'

- name: TiDB Skip Binlog Count:by_instance
  unit: "1"
  metricsType: "Gauge"
  expr: 'max(tidb_server_critical_error_total) by(instance)'
  component: TiDB
  chartTitle: 'TiDB Skip Binlog Count-by_instance'
  dashboard:
    - title: 'TiDB-Server-Skip Binlog Count'

- name: TiDB Connection Count:total
  unit: "1"
  metricsType: "Gauge"
  expr: 'sum(tidb_server_connections)'
  component: TiDB
  chartTitle: 'TiDB-Connection Count-total'
  dashboard:
    - title: 'TiDB-Server-Connection Count'

- name: TiDB Connection Count:by_instance
  unit: "1"
  metricsType: "Gauge"
  expr: 'tidb_server_connections'
  component: TiDB
  chartTitle: 'TiDB-Connection Count-by_instance'
  dashboard:
    - title: 'TiDB-Server-Connection Count'

- name: TiDB Uptime:by_instance
  stats: enable
  unit: "1"
  metricsType: "Gauge"
  expr: '(time() - process_start_time_seconds{job="tidb"})'
  component: TiDB
  chartTitle: 'TiDB-Uptime-by_instance'
  dashboard:
    - title: 'TiDB-Server-Uptime'

- name: TiKV Uptime:by_instance
  stats: enable
  unit: "1"
  metricsType: "Gauge"
  expr: '(time() - process_start_time_seconds{job="tikv"})'
  component: TiKV
  chartTitle: 'TiKV-Uptime-by_instance'
  dashboard:
    - title: 'TiKV-Server-Uptime'

- name: PD Uptime:by_instance
  stats: enable
  unit: "1"
  metricsType: "Gauge"
  expr: '(time() - process_start_time_seconds{job="pd"})'
  component: PD
  chartTitle: 'PD-Uptime-by_instance'
  dashboard:
    - title: 'PD-Server-Uptime'

- name: SQL Phase:TiDB Parse Duration:by_sql_type
  stats: enable
  unit: "µs"
  metricsType: "Histogram"
  expr: 'histogram_quantile(0.95, sum(rate(tidb_session_parse_duration_seconds_bucket[1m])) by(le, sql_type))'
  component: TiDB
  chartTitle: 'TiDB Parse Duration-by_sql_type'
  dashboard:
    - title: 'TiDB-Executor-Parse Duration'

- name: TiDB Compile Duration:by_sql_type
  stats: enable
  unit: "µs"
  metricsType: "Histogram"
  expr: 'histogram_quantile(0.95, sum(rate(tidb_session_compile_duration_seconds_bucket[1m])) by(le, sql_type))'
  component: TiDB
  chartTitle: 'TiDB Compile Duration-by_sql_type'
  dashboard:
    - title: 'TiDB-Executor-Compile Duration'

- name: Queries Using Plan Cache OPS:by_type
  stats: enable
  unit: "1"
  metricsType: "Counter"
  expr: 'sum(rate(tidb_server_plan_cache_total[1m])) by (type)'
  component: TiDB
  chartTitle: 'TiDB-Queries Using Plan Cache OPS-by_type'
  dashboard:
    - title: 'Performance-Overview-TiDB-Queries Using Plan Cache OPS'

- name: 数据同步效率:TiKV Commit log duration:total
  stats: enable
  unit: "ms"
  metricsType: "Histogram"
  expr: 'histogram_quantile(0.99, sum(rate(tikv_raftstore_commit_log_duration_seconds_bucket[1m])) by(le))'
  component: TiKV
  chartTitle: 'TiKV Commit log duration-total'
  dashboard:
    - title: 'TiKV-Detail-Raft IO-99% Commit log duration per server'




