# expr can be written as follow:
# 1. seperate cloud and op expression if there are too many differences
# expr:
#   cloud: 'label_replace(time()-process_start_time_seconds{{label_cluster_id},component="tidb"},"name","$1","instance","(.*)")'
#   op: 'label_replace(time()-process_start_time_seconds{{label_cluster_id},job="tidb"},"name","$1","instance","(.*)")'
# or
# 2. unite to one expression and replace some fields
# expr: 'label_replace(sum(tidb_server_connections{{label_cluster_id}}),"name","total","","")'

# Connections
- name: Connnection_count:total
  unit: "1"
  expr: 'label_replace(sum(tidb_server_connections{{label_cluster_id}}),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Connnection_count:by_instance
  unit: "1"
  expr: 'label_replace(sum(tidb_server_connections{{label_cluster_id}})by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: Active_connection_count:total
  unit: "1"
  #expr: 'label_replace(sum(rate(tidb_server_handle_query_duration_seconds_sum{{label_cluster_id},sql_type!="internal"}[2m])),"name","total","","")'
  expr: 'label_replace(sum(tidb_server_tokens{{label_cluster_id}}),"name","total","","")'
  component: TiDB
  dashboard:
  
- name: Active_connection_count:by_instance
  unit: "1"
  #expr: 'label_replace(sum(rate(tidb_server_handle_query_duration_seconds_sum{{label_cluster_id},sql_type!="internal"}[2m])),"name","total","","")'
  expr: 'label_replace(sum(tidb_server_tokens{{label_cluster_id}})by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: Disconnection_count_noOK:total
  unit: "1"
  expr: 'label_replace(sum(tidb_server_disconnection_total{{label_cluster_id},result="undetermined|error"}),"name","total","","")'
  component: TiDB
  dashboard:

- name: Disconnection_rate_OK:total
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_server_disconnection_total{{label_cluster_id},result="ok"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  
- name: Disconnection_count:by_orthogonality
  unit: "1"
  expr: 'label_replace(label_replace(sum(tidb_server_disconnection_total{{label_cluster_id}})by(instance,result),"name1","$1","instance","(.*)"),"name2","$1","result","(.*)")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

# Requests
- name: TPS:total
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_session_transaction_duration_seconds_count{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: TPS:by_instance
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_session_transaction_duration_seconds_count{{label_cluster_id}}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'
  
- name: TPS:by_orthogonality
  unit: "1"
  expr: 'label_replace(label_replace(sum(rate(tidb_session_transaction_duration_seconds_count{{label_cluster_id}}[2m]))by(type,txn_mode),"name1","$1","type","(.*)"),"name2","$1","txn_mode","(.*)")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: Transaction_retry_count:total
  unit: "1"
  expr: 'label_replace(sum(increase(tidb_session_retry_num_bucket{{label_cluster_id}}[2m]))by(le),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: QPS:total
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_executor_statement_total{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'
  
- name: QPS:by_instance
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_executor_statement_total{{label_cluster_id}}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: QPS:by_type
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_executor_statement_total{{label_cluster_id}}[2m]))by(type),"name","$1","type","(.*)")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'
  
- name: QPS_read:total
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_executor_statement_total{{label_cluster_id},type="Select"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  
- name: QPS_write:total
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_executor_statement_total{{label_cluster_id},type=~"Insert|Update|Delete"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  
- name: QPS_ddl:total
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_executor_statement_total{{label_cluster_id},type=~"AlterTable|CompactTable|CreateDatabase|CreateIndex|CreateTable|CreateView|DropDatabase|DropIndex|DropView|DropTable|TruncateTable"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:

- name: QPS_ddl:by_type
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_executor_statement_total{{label_cluster_id},type=~"AlterTable|CompactTable|CreateDatabase|CreateIndex|CreateTable|CreateView|DropDatabase|DropIndex|DropView|DropTable|TruncateTable"}[2m]))by(type),"name","$1","type","(.*)")'
  component: TiDB
  dashboard:

- name: QPS_other:total
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_executor_statement_total{{label_cluster_id},type!~"Select|Insert|Update|Delete|AlterTable|CompactTable|CreateDatabase|CreateIndex|CreateTable|CreateView|DropDatabase|DropIndex|DropView|DropTable|TruncateTable"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:

- name: QPS_failed:total
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_server_execute_error_total{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: CPS:total
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_server_query_total{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: CPS:by_type
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_server_query_total{{label_cluster_id}}[2m]))by(type),"name","$1","type","(.*)")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Plan_cache_OPS:total
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_server_plan_cache_total{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Plan_cache_miss_OPS:total
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_server_plan_cache_miss_total{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: TSO_request_OPS:total
  unit: "1"
  expr: 'label_replace(sum(rate(pd_client_request_handle_requests_duration_seconds_count{{label_cluster_id},type="tso"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

#- name: KV_request_OPS:total
#  unit: "1"
#  expr: 'label_replace(sum(rate(tidb_tikvclient_request_seconds_count{{label_cluster_id}}[2m])),"name","total","","")'
#  component: TiDB

# version: v6.2 the same with the above metric
- name: KV_Request_OPS:total
  unit: "1"
  # expr: 'label_replace(sum(rate(tidb_tikvclient_request_counter{{label_cluster_id}}[2m])),"name","total","","")'
  expr: 'label_replace(sum(rate(tidb_tikvclient_request_seconds_count{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

# version: 6.2
- name: KV_Request_OPS_Internal:total
  unit: "1"
  expr: 'label_replace(sum(rate(tidb_tikvclient_request_time_counter{{label_cluster_id},source=~"internal.*"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

# version: v6.2
- name: KV_Request_OPS:by_orthogonality
  unit: "1"
  expr: 'label_replace(label_replace(label_replace(sum(rate(tidb_tikvclient_request_counter{{label_cluster_id}}[2m]))by(instance,type,source),"name1","$1","instance","(.*)"),"name2","$1","type","(.*)"),"name3","$1","source","(.*)")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

# Database time
- name: Database_time:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_handle_query_duration_seconds_sum{{label_cluster_id},sql_type!="internal"}[2m])),"name","total","","")'
  component:  TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Database_time:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_handle_query_duration_seconds_sum{{label_cluster_id},sql_type!="internal"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: Database_time:by_type
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_handle_query_duration_seconds_sum{{label_cluster_id},sql_type!="internal"}[2m]))by(sql_type),"name","$1","sql_type","(.*)")'
  component:  TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Get_token_time:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_get_token_duration_seconds_sum{{label_cluster_id}}[2m]))/1000000,"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Parse_time:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_session_parse_duration_seconds_sum{{label_cluster_id},sql_type="general"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Compile_time:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_session_compile_duration_seconds_sum{{label_cluster_id},sql_type="general"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Execute_time:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_session_execute_duration_seconds_sum{{label_cluster_id},sql_type="general"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: SQL_execute_time:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_tikvclient_request_seconds_sum{{label_cluster_id},store!="0"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: SQL_execute_time:by_type
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_tikvclient_request_seconds_sum{{label_cluster_id},store!="0"}[2m]))by(type),"name","$1","type","(.*)")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Wait_start_TSO_time:total
  unit: "s"
  expr: 'label_replace(sum(rate(pd_client_cmd_handle_cmds_duration_seconds_sum{{label_cluster_id},type="wait"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

# TiDB Duration/Latency
- name: Avg_idle_connection_duration_in_txn:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_conn_idle_duration_seconds_sum{{label_cluster_id},in_txn="1"}[2m]))/sum(rate(tidb_server_conn_idle_duration_seconds_count{{label_cluster_id},in_txn="1"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_idle_connection_duration_in_txn:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_conn_idle_duration_seconds_sum{{label_cluster_id},in_txn="1"}[2m]))by(instance)/sum(rate(tidb_server_conn_idle_duration_seconds_count{{label_cluster_id},in_txn="1"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: P99_idle_connection_duration_in_txn:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tidb_server_conn_idle_duration_seconds_bucket{{label_cluster_id},in_txn="1"}[2m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P90_idle_connection_duration_in_txn:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.90,sum(rate(tidb_server_conn_idle_duration_seconds_bucket{{label_cluster_id},in_txn="1"}[2m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_idle_connection_duration_not_in_txn:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_conn_idle_duration_seconds_sum{{label_cluster_id},in_txn="0"}[2m]))/sum(rate(tidb_server_conn_idle_duration_seconds_count{{label_cluster_id},in_txn="0"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_idle_connection_duration_not_in_txn:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_conn_idle_duration_seconds_sum{{label_cluster_id},in_txn="0"}[2m]))by(instance)/sum(rate(tidb_server_conn_idle_duration_seconds_count{{label_cluster_id},in_txn="0"}[2m]))by(instance),"name","total","","")'
  component: TiDB
  dashboard:

- name: P99_idle_connection_duration_not_in_txn:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tidb_server_conn_idle_duration_seconds_bucket{{label_cluster_id},in_txn="0"}[2m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P90_idle_connection_duration_not_in_txn:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.90,sum(rate(tidb_server_conn_idle_duration_seconds_bucket{{label_cluster_id},in_txn="0"}[2m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_query_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_handle_query_duration_seconds_sum{{label_cluster_id},sql_type!="internal"}[2m]))/sum(rate(tidb_server_handle_query_duration_seconds_count{{label_cluster_id},sql_type!="internal"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_query_duration:by_type
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_handle_query_duration_seconds_sum{{label_cluster_id},sql_type!="internal"}[2m]))by(sql_type)/sum(rate(tidb_server_handle_query_duration_seconds_count{{label_cluster_id},sql_type!="internal"}[2m]))by(sql_type),"name","$1","sql_type","(.*)")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_query_duration_read:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_handle_query_duration_seconds_sum{{label_cluster_id},sql_type="Select"}[2m]))/sum(rate(tidb_server_handle_query_duration_seconds_count{{label_cluster_id},sql_type="Select"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:

- name: Avg_query_duration_read:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_handle_query_duration_seconds_sum{{label_cluster_id},sql_type="Select"}[2m]))by(instance)/sum(rate(tidb_server_handle_query_duration_seconds_count{{label_cluster_id},sql_type="Select"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: Avg_query_duration_write:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_handle_query_duration_seconds_sum{{label_cluster_id},sql_type=~"Insert|Update|Delete"}[2m]))/sum(rate(tidb_server_handle_query_duration_seconds_count{{label_cluster_id},sql_type=~"Insert|Update|Delete"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:

- name: Avg_query_duration_write:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_handle_query_duration_seconds_sum{{label_cluster_id},sql_type=~"Insert|Update|Delete"}[2m]))by(instance)/sum(rate(tidb_server_handle_query_duration_seconds_count{{label_cluster_id},sql_type=~"Insert|Update|Delete"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: Avg_query_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_handle_query_duration_seconds_sum{{label_cluster_id},sql_type!="internal"}[2m]))by(instance)/sum(rate(tidb_server_handle_query_duration_seconds_count{{label_cluster_id},sql_type!="internal"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: P99_query_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tidb_server_handle_query_duration_seconds_bucket{{label_cluster_id},sql_type!="internal"}[2m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P90_query_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.90,sum(rate(tidb_server_handle_query_duration_seconds_bucket{{label_cluster_id},sql_type!="internal"}[2m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'
  
- name: P99_query_duration:by_type
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tidb_server_handle_query_duration_seconds_bucket{{label_cluster_id},sql_type!="internal"}[2m]))by(le,sql_type)),"name","$1","sql_type","(.*)")'
  component: TiDB
  dashboard:

- name: Avg_transaction_duration:by_orthogonality
  unit: "s"
  expr: 'label_replace(label_replace(sum(rate(tidb_session_transaction_duration_seconds_sum{{label_cluster_id}}[2m]))by(type,txn_mode)/sum(rate(tidb_session_transaction_duration_seconds_count{{label_cluster_id}}[2m]))by(type,txn_mode),"name1","$1","type","(.*)"),"name2","$1","txn_mode","(.*)")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: Avg_transaction_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_session_transaction_duration_seconds_sum{{label_cluster_id}}[2m]))/sum(rate(tidb_session_transaction_duration_seconds_count{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: Avg_transaction_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_session_transaction_duration_seconds_sum{{label_cluster_id}}[2m]))by(instance)/sum(rate(tidb_session_transaction_duration_seconds_count{{label_cluster_id}}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: Avg_slow_query_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_slow_query_wait_duration_seconds_sum{{label_cluster_id}}[2m]))/sum(rate(tidb_server_slow_query_wait_duration_seconds_count{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: Avg_slow_query_duration:by_type
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_slow_query_wait_duration_seconds_sum{{label_cluster_id}}[2m]))by(sql_type)/sum(rate(tidb_server_slow_query_wait_duration_seconds_count{{label_cluster_id}}[2m]))by(sql_type),"name","$1","sql_type","(.*)")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: P99_get_token_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tidb_server_get_token_duration_seconds_bucket{{label_cluster_id}}[1m]))by(le))/1000000,"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P90_get_token_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.90,sum(rate(tidb_server_get_token_duration_seconds_bucket{{label_cluster_id}}[1m]))by(le))/1000000,"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P99_get_token_duration:by_instance
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tidb_server_get_token_duration_seconds_bucket{{label_cluster_id}}[1m]))by(le,instance))/1000000,"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: Avg_get_token_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_get_token_duration_seconds_sum{{label_cluster_id}}[2m]))/sum(rate(tidb_server_get_token_duration_seconds_count{{label_cluster_id}}[2m]))/1000000,"name","get_token_duration","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_get_token_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_server_get_token_duration_seconds_sum{{label_cluster_id}}[2m]))by(instance)/sum(rate(tidb_server_get_token_duration_seconds_count{{label_cluster_id}}[2m]))by(instance)/1000000,"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: P99_parse_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tidb_session_parse_duration_seconds_bucket{{label_cluster_id},sql_type="general"}[2m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P90_parse_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.90,sum(rate(tidb_session_parse_duration_seconds_bucket{{label_cluster_id},sql_type="general"}[2m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'
  
- name: P99_parse_duration:by_instance
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tidb_session_parse_duration_seconds_bucket{{label_cluster_id},sql_type="general"}[2m]))by(le,instance)),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: Avg_parse_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_session_parse_duration_seconds_sum{{label_cluster_id},sql_type="general"}[2m]))/sum(rate(tidb_session_parse_duration_seconds_count{{label_cluster_id},sql_type="general"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_parse_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_session_parse_duration_seconds_sum{{label_cluster_id},sql_type="general"}[2m]))by(instance)/sum(rate(tidb_session_parse_duration_seconds_count{{label_cluster_id},sql_type="general"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: P99_compile_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tidb_session_compile_duration_seconds_bucket{{label_cluster_id},sql_type="general"}[2m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P90_compile_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.90,sum(rate(tidb_session_compile_duration_seconds_bucket{{label_cluster_id},sql_type="general"}[2m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'
  
- name: P99_compile_duration:by_instance
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tidb_session_compile_duration_seconds_bucket{{label_cluster_id},sql_type="general"}[2m]))by(le,instance)),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: Avg_compile_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_session_compile_duration_seconds_sum{{label_cluster_id},sql_type="general"}[2m]))/sum(rate(tidb_session_compile_duration_seconds_count{{label_cluster_id},sql_type="general"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_compile_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_session_compile_duration_seconds_sum{{label_cluster_id},sql_type="general"}[2m]))by(instance)/sum(rate(tidb_session_compile_duration_seconds_count{{label_cluster_id},sql_type="general"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: P99_execute_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tidb_session_execute_duration_seconds_bucket{{label_cluster_id},sql_type="general"}[2m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P90_execute_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.90,sum(rate(tidb_session_execute_duration_seconds_bucket{{label_cluster_id},sql_type="general"}[2m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'
  
- name: P99_execute_duration:by_instance
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tidb_session_execute_duration_seconds_bucket{{label_cluster_id},sql_type="general"}[2m]))by(le,instance)),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: Avg_execute_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_session_execute_duration_seconds_sum{{label_cluster_id},sql_type="general"}[2m]))/sum(rate(tidb_session_execute_duration_seconds_count{{label_cluster_id},sql_type="general"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_execute_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_session_execute_duration_seconds_sum{{label_cluster_id},sql_type="general"}[2m]))by(instance)/sum(rate(tidb_session_execute_duration_seconds_count{{label_cluster_id},sql_type="general"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: Avg_KV_request_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_tikvclient_request_seconds_sum{{label_cluster_id},store!="0"}[2m]))/sum(rate(tidb_tikvclient_request_seconds_count{{label_cluster_id},store!="0"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_KV_request_duration:by_type
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_tikvclient_request_seconds_sum{{label_cluster_id},store!="0"}[2m]))by(type)/sum(rate(tidb_tikvclient_request_seconds_count{{label_cluster_id},store!="0"}[2m]))by(type),"name","$1","type","(.*)")'
  component: TiDB
  dashboard:
  
- name: Avg_PD_wait_TSO_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(pd_client_cmd_handle_cmds_duration_seconds_sum{{label_cluster_id},type="wait"}[2m]))/sum(rate(pd_client_cmd_handle_cmds_duration_seconds_count{{label_cluster_id},type="wait"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'
  
- name: Avg_PD_wait_TSO_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(pd_client_cmd_handle_cmds_duration_seconds_sum{{label_cluster_id},type="wait"}[2m]))by(instance)/sum(rate(pd_client_cmd_handle_cmds_duration_seconds_count{{label_cluster_id},type="wait"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:
  
- name: P99_PD_wait_TSO_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(pd_client_cmd_handle_cmds_duration_seconds_bucket{{label_cluster_id}, type="wait"}[2m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_PD_grpc_TSO_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(pd_client_request_handle_requests_duration_seconds_sum{{label_cluster_id},type="tso"}[2m]))/sum(rate(pd_client_request_handle_requests_duration_seconds_count{{label_cluster_id},type="tso"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P99_PD_grpc_TSO_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(pd_client_request_handle_requests_duration_seconds_bucket{{label_cluster_id},type="tso"}[2m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P99_transaction_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tidb_session_transaction_duration_seconds_bucket{{label_cluster_id}}[1m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: P90_transaction_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.90,sum(rate(tidb_session_transaction_duration_seconds_bucket{{label_cluster_id}}[1m]))by(le)),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'
  
- name: P99_transaction_duration:by_type
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tidb_session_transaction_duration_seconds_bucket{{label_cluster_id}}[1m]))by(le,txn_mode)),"name","$1","txn_mode","(.*)")'
  component: TiDB
  dashboard:
  - title: 'Overview'
    id: 'eDbRZpnWk/overview'
  
- name: Avg_transaction_duration:by_type
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_session_transaction_duration_seconds_sum{{label_cluster_id}}[2m]))by(txn_mode)/sum(rate(tidb_session_transaction_duration_seconds_count{{label_cluster_id}}[2m]))by(txn_mode),"name","$1","txn_mode","(.*)")'
  component: TiDB
  dashboard:

# TiKV duration/latency
- name: Avg_TiKV_gRPC_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_sum{{label_cluster_id}}[2m]))/sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: Avg_TiKV_gRPC_duration:by_type
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_sum{{label_cluster_id}}[2m]))by(type)/sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id}}[2m]))by(type),"name","$1","type","(.*)")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_async_write_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_storage_engine_async_request_duration_seconds_sum{{label_cluster_id},type="write"}[2m]))/sum(rate(tikv_storage_engine_async_request_duration_seconds_count{{label_cluster_id},type="write"}[2m])),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P99_async_write_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tikv_storage_engine_async_request_duration_seconds_bucket{{label_cluster_id},type="write"}[2m]))by(le)),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_async_write_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_storage_engine_async_request_duration_seconds_sum{{label_cluster_id},type="write"}[2m]))by(instance)/sum(rate(tikv_storage_engine_async_request_duration_seconds_count{{label_cluster_id},type="write"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:

- name: Avg_store_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_raftstore_store_duration_secs_sum{{label_cluster_id}}[2m]))/sum(rate(tikv_raftstore_store_duration_secs_count{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P99_store_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tikv_raftstore_store_duration_secs_bucket{{label_cluster_id}}[2m]))by(le)),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_store_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_raftstore_store_duration_secs_sum{{label_cluster_id}}[2m]))by(instance)/sum(rate(tikv_raftstore_store_duration_secs_count{{label_cluster_id}}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:

- name: Avg_apply_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_raftstore_apply_duration_secs_sum{{label_cluster_id}}[2m]))/sum(rate(tikv_raftstore_apply_duration_secs_count{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P99_apply_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tikv_raftstore_apply_duration_secs_bucket{{label_cluster_id}}[2m]))by(le)),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_apply_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_raftstore_apply_duration_secs_sum{{label_cluster_id}}[2m]))by(instance)/sum(rate(tikv_raftstore_apply_duration_secs_count{{label_cluster_id}}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:

- name: Avg_append_log_duration:total
  unit: "s"
  expr: 'label_replace((sum(rate(tikv_raftstore_append_log_duration_seconds_sum{{label_cluster_id}}[2m]))/sum(rate(tikv_raftstore_append_log_duration_seconds_count{{label_cluster_id}}[2m]))),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P99_append_log_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tikv_raftstore_append_log_duration_seconds_bucket{{label_cluster_id}}[2m]))by(le)),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_commit_log_duration:total
  unit: "s"
  expr: 'label_replace((sum(rate(tikv_raftstore_commit_log_duration_seconds_sum{{label_cluster_id}}[2m]))/sum(rate(tikv_raftstore_commit_log_duration_seconds_count{{label_cluster_id}}[2m]))),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P99_commit_log_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99, sum(rate(tikv_raftstore_commit_log_duration_seconds_bucket{{label_cluster_id}}[2m]))by(le)),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: Avg_apply_log_duration:total
  unit: "s"
  expr: 'label_replace((sum(rate(tikv_raftstore_apply_log_duration_seconds_sum{{label_cluster_id}}[2m]))/sum(rate(tikv_raftstore_apply_log_duration_seconds_count{{label_cluster_id}}[2m]))),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: P99_apply_log_duration:total
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99, sum(rate(tikv_raftstore_apply_log_duration_seconds_bucket{{label_cluster_id}}[2m]))by(le)),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

# Resource
- name: TiDB_uptime:by_instance
  unit: "s"
  expr: 'label_replace(time()-process_start_time_seconds{{label_cluster_id},{label_component}="tidb"},"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: TiDB_cpu_usage_norm:total
  unit: "%"
  expr: 'label_replace(avg(rate(process_cpu_seconds_total{{label_cluster_id},{label_component}="tidb"}[2m]))/avg(tidb_server_maxprocs{{label_cluster_id},{label_component}="tidb"})*100,"name","total","","")'
  component: TiDB
  dashboard:

- name: TiDB_cpu_usage_norm:by_instance
  unit: "%"
  expr: 'label_replace(rate(process_cpu_seconds_total{{label_cluster_id},{label_component}="tidb"}[2m])/tidb_server_maxprocs{{label_cluster_id},{label_component}="tidb"}*100,"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: TiDB_CPU_usage:by_instance
  unit: "%"
  expr: 'label_replace(rate(process_cpu_seconds_total{{label_cluster_id},{label_component}="tidb"}[2m])*100,"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: TiDB_CPU_delta:total
  unit: "%"
  expr: 'label_replace((max(rate(process_cpu_seconds_total{{label_cluster_id},{label_component}="tidb"}[2m]))-min(rate(process_cpu_seconds_total{{label_cluster_id},{label_component}="tidb"}[2m])))*100,"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id: 
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: TiDB_CPU_max:total
  unit: "%"
  expr: 'label_replace(max(rate(process_cpu_seconds_total{{label_cluster_id},{label_component}="tidb"}[2m]))*100,"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id: 
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: TiDB_memory_usage:by_instance
  unit: "Bytes"
  expr: 'label_replace(process_resident_memory_bytes{{label_cluster_id},{label_component}="tidb"},"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: TiDB_memory_delta:total
  unit: "Bytes"
  expr: 'label_replace((max(process_resident_memory_bytes{{label_cluster_id},{label_component}="tidb"})-min(process_resident_memory_bytes{{label_cluster_id},{label_component}="tidb"})),"name","TiDB_memory_delta","","")'
  component: TiDB
  dashboard:

- name: TiDB_memory_max:total
  unit: "Bytes"
  expr: 'label_replace(max(process_resident_memory_bytes{{label_cluster_id},{label_component}="tidb"}),"name","total","","")'
  component: TiDB
  dashboard:

# cluster_id not right on cloud 'cluster_id="tidbxxxxxxxxxxxxxxx"'
# - name: TiDB_memory_usage:by_type_instance
#   unit: "Bytes"
#   expr: 'label_replace(label_replace(tidb_server_memory_usage{{label_cluster_id},{label_component}="tidb"}by(type),"name1","$1","type","(.*)")by(instance),"name2","$1","instance","(.*)")'
#   component: TiDB

# not supported on cloud
# - name: TiDB_memory_heapinuse:by_instance
#   unit: "Bytes"
#   expr: 'label_replace(go_memory_classes_heap_objects_bytes{{label_cluster_id},{label_component}="tidb"}+go_memory_classes_heap_unused_bytes{{label_cluster_id},{label_component}="tidb"},"name","$1","instance","(.*)")'
#   component: TiDB

- name: TiKV_uptime:by_instance
  unit: "s"
  expr: 'label_replace(time()-process_start_time_seconds{{label_cluster_id},{label_component}="tikv"},"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: TiKV_memory_usage:by_instance
  unit: "Bytes"
  expr: 'label_replace(process_resident_memory_bytes{{label_cluster_id},{label_component}="tikv"},"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: TiKV_memory_delta:total
  unit: "Bytes"
  expr: 'label_replace((max(process_resident_memory_bytes{{label_cluster_id},{label_component}="tikv"})-min(process_resident_memory_bytes{{label_cluster_id},{label_component}="tikv"})),"name","tikv_memory_delta","","")'
  component: TiKV
  dashboard:

- name: TiKV_memory_max:total
  unit: "Bytes"
  expr: 'label_replace(max(process_resident_memory_bytes{{label_cluster_id},{label_component}="tikv"}),"name","tikv_memory_max","","")'
  component: TiKV
  dashboard:

- name: TiKV_cpu_usage_norm:total
  unit: "%"
  expr: 'label_replace(sum(rate(tikv_thread_cpu_seconds_total{{label_cluster_id}}[2m]))/sum(tikv_server_cpu_cores_quota{{label_cluster_id}})*100,"name","total","","")'
  component: TiKV
  dashboard:

- name: TiKV_cpu_usage_norm:by_instance
  unit: "%"
  expr: 'label_replace(sum(rate(tikv_thread_cpu_seconds_total{{label_cluster_id}}[2m]))by(instance)/sum(tikv_server_cpu_cores_quota{{label_cluster_id},{label_component}="tikv"})by(instance)*100,"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:

- name: TiKV_CPU_usage:by_instance
  unit: "%"
  expr: 'label_replace(sum(rate(tikv_thread_cpu_seconds_total{{label_cluster_id}}[2m]))by(instance)*100,"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: TiKV_CPU_delta:total
  unit: "%"
  expr: 'label_replace((max(sum(rate(tikv_thread_cpu_seconds_total{{label_cluster_id}}[2m]))by(instance))-min(sum(rate(tikv_thread_cpu_seconds_total{{label_cluster_id}}[2m]))by(instance)))*100,"name","tikv_cpu_delta","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id: 
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: TiKV_CPU_max:total
  unit: "%"
  expr: 'label_replace(max(sum(rate(tikv_thread_cpu_seconds_total{{label_cluster_id}}[2m]))by(instance))*100,"name","tikv_cpu_max","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: TiKV_disk_usage:by_instance
  unit: "%"
  expr: 'label_replace(sum(tikv_engine_size_bytes{{label_cluster_id}})by(instance)/sum(tikv_store_size_bytes{{label_cluster_id},type="capacity"})by(instance)*100,"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:

- name: TiKV_disk_capacity:by_instance
  unit: "Bytes"
  expr: 'label_replace(sum(tikv_store_size_bytes{{label_cluster_id},type="capacity"})by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: TiKV_disk_used:by_instance
  unit: "Bytes"
  expr: 'label_replace(sum(tikv_engine_size_bytes{{label_cluster_id}})by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: TiKV_disk_usage_delta:total
  unit: "%"
  expr: 'label_replace((max(sum(tikv_engine_size_bytes{{label_cluster_id}})by(instance)/sum(tikv_store_size_bytes{{label_cluster_id},type="capacity"})by(instance))-min(sum(tikv_engine_size_bytes{{label_cluster_id}})by(instance)/sum(tikv_store_size_bytes{{label_cluster_id},type="capacity"})by(instance)))*100,"name","tikv_disg_usage_delta","","")'
  component: TiKV
  dashboard:

- name: TiKV_disk_usage_max:total
  unit: "%"
  expr: 'label_replace(max(sum(tikv_engine_size_bytes{{label_cluster_id}})by(instance)/sum(tikv_store_size_bytes{{label_cluster_id},type="capacity"})by(instance))*100,"name","tikv_disk_usage_max","","")'
  component: TiKV
  dashboard:

- name: TiKV_IO_read_MBps:by_instance
  unit: "Bps"
  expr: 'label_replace(sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="kv",type=~"bytes_read|iter_bytes_read"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: TiKV_IO_read_MBps:total
  unit: "Bps"
  expr: 'label_replace(sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="kv",type=~"bytes_read|iter_bytes_read"}[2m])),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: TiKV_IO_write_MBps:by_instance
  unit: "Bps"
  expr: 'label_replace(sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="kv",type="wal_file_bytes"}[2m]))by(instance)+(sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="raft",type="wal_file_bytes"}[2m]))by(instance)or(0*sum(rate(raft_engine_write_size_sum{{label_cluster_id}}[2m]))by(instance)))+(sum(rate(raft_engine_write_size_sum{{label_cluster_id}}[2m]))by(instance)or(0*sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="raft",type="wal_file_bytes"}[2m]))by(instance))),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: TiKV_IO_write_MBps:total
  unit: "Bps"
  expr: 'label_replace(sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="kv",type="wal_file_bytes"}[2m]))+(sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="raft",type="wal_file_bytes"}[2m]))or(0*sum(rate(raft_engine_write_size_sum{{label_cluster_id}}[2m]))))+(sum(rate(raft_engine_write_size_sum{{label_cluster_id}}[2m]))or(0*sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="raft",type="wal_file_bytes"}[2m])))),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: TiKV_full_remain_time:by_instance
  unit: "s"
  expr: 'label_replace((sum(tikv_store_size_bytes{{label_cluster_id},type="capacity"})by(instance)*0.8-sum(tikv_engine_size_bytes{{label_cluster_id}})by(instance))/(sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="kv",type="wal_file_bytes"}[10m]))by(instance)+(sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="raft",type="wal_file_bytes"}[10m]))by(instance)or(0*sum(rate(raft_engine_write_size_sum{{label_cluster_id}}[10m]))by(instance)))+(sum(rate(raft_engine_write_size_sum{{label_cluster_id}}[10m]))by(instance)or(0*sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="raft",type="wal_file_bytes"}[10m]))by(instance)))),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:

- name: TiKV_IO_MBps:by_instance
  unit: "Bps"
  expr: 'label_replace(sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="kv",type=~"bytes_read|iter_bytes_read|wal_file_bytes"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: TiKV_IO_MBps_delta:total
  unit: "Bps"
  expr: 'label_replace((max(sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="kv",type=~"bytes_read|iter_bytes_read|wal_file_bytes"}[2m]))by(instance))-min(sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="kv",type=~"bytes_read|iter_bytes_read|wal_file_bytes"}[2m]))by(instance))),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: TiKV_IO_MBps_max:total
  unit: "Bps"
  expr: 'label_replace(max(sum(rate(tikv_engine_flow_bytes{{label_cluster_id},db="kv",type=~"bytes_read|iter_bytes_read|wal_file_bytes"}[2m]))by(instance)),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Performance-Overview'
    id:
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: TiFlash_uptime:by_instance
  unit: "s"
  expr: 'label_replace(tiflash_system_asynchronous_metric_Uptime{{label_cluster_id}},"name","$1","instance","(.*)")'
  component: TiFlash
  dashboard:
  - title: 'TiFlash-Summary'
    id:
      cloud: 'kWxNAVnGztidbcloudmaster/tiflash-proxy-details-cluster-clinic'
      op: 'kWxNAVnGzclustermaster/tiflash-proxy-details-cluster-clinic'
  
- name: TiFlash_CPU_usage:by_instance
  unit: "%"
  expr: 'label_replace(rate(tiflash_proxy_process_cpu_seconds_total{{label_cluster_id},{label_component}="tiflash"}[2m])*100,"name","$1","instance","(.*)")'
  component: TiFlash
  dashboard:
  - title: 'TiFlash-Summary'
    id:
      cloud: 'kWxNAVnGztidbcloudmaster/tiflash-proxy-details-cluster-clinic'
      op: 'kWxNAVnGzclustermaster/tiflash-proxy-details-cluster-clinic'

- name: TiFlash_memory_usage:by_instance
  unit: "Bytes"
  expr: 'label_replace(tiflash_proxy_process_resident_memory_bytes{{label_cluster_id},{label_component}="tiflash"},"name","$1","instance","(.*)")'
  component: TiFlash
  dashboard:
  - title: 'TiFlash-Summary'
    id:
      cloud: 'kWxNAVnGztidbcloudmaster/tiflash-proxy-details-cluster-clinic'
      op: 'kWxNAVnGzclustermaster/tiflash-proxy-details-cluster-clinic'

- name: TiFlash_disk_usage:by_instance
  unit: "%"
  expr: 'label_replace(sum(tiflash_system_current_metric_StoreSizeUsed{{label_cluster_id}})by(instance)/sum(tiflash_system_current_metric_StoreSizeCapacity{{label_cluster_id}})by(instance)*100,"name","$1","instance","(.*)")'
  component: TiFlash
  dashboard:

- name: TiFlash_disk_capacity:by_instance
  unit: "Bytes"
  expr: 'label_replace(sum(tiflash_system_current_metric_StoreSizeCapacity{{label_cluster_id}})by(instance),"name","$1","instance","(.*)")'
  component: TiFlash
  dashboard:
  - title: 'TiFlash-Summary'
    id:
      cloud: 'kWxNAVnGztidbcloudmaster/tiflash-proxy-details-cluster-clinic'
      op: 'kWxNAVnGzclustermaster/tiflash-proxy-details-cluster-clinic'

- name: TiFlash_disk_used:by_instance
  unit: "Bytes"
  expr: 'label_replace(sum(tiflash_system_current_metric_StoreSizeUsed{{label_cluster_id}})by(instance),"name","$1","instance","(.*)")'
  component: TiFlash
  dashboard:
  - title: 'TiFlash-Summary'
    id:
      cloud: 'kWxNAVnGztidbcloudmaster/tiflash-proxy-details-cluster-clinic'
      op: 'kWxNAVnGzclustermaster/tiflash-proxy-details-cluster-clinic'

- name: TiFlash_IO_read_MBps:by_instance
  unit: "Bps"
  expr: 'label_replace(sum(rate(tiflash_system_profile_event_ReadBufferFromFileDescriptorReadBytes{{label_cluster_id}}[2m]))by(instance)+sum(rate(tiflash_system_profile_event_PSMReadBytes{{label_cluster_id}}[2m]))by(instance)+sum(rate(tiflash_system_profile_event_ReadBufferAIOReadBytes{{label_cluster_id}}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiFlash
  dashboard:

- name: TiFlash_IO_read_MBps:total
  unit: "Bps"
  expr: 'label_replace(sum(rate(tiflash_system_profile_event_ReadBufferFromFileDescriptorReadBytes{{label_cluster_id}}[2m]))+sum(rate(tiflash_system_profile_event_PSMReadBytes{{label_cluster_id}}[2m]))+sum(rate(tiflash_system_profile_event_ReadBufferAIOReadBytes{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiFlash
  dashboard:

- name: TiFlash_IO_write_MBps:by_instance
  unit: "Bps"
  expr: 'label_replace(sum(rate(tiflash_system_profile_event_WriteBufferFromFileDescriptorWriteBytes{{label_cluster_id}}[2m]))by(instance)+sum(rate(tiflash_system_profile_event_PSMWriteBytes{{label_cluster_id}}[2m]))by(instance)+sum(rate(tiflash_system_profile_event_WriteBufferAIOWriteBytes{{label_cluster_id}}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiFlash
  dashboard:

- name: TiFlash_IO_write_MBps:total
  unit: "Bps"
  expr: 'label_replace(sum(rate(tiflash_system_profile_event_WriteBufferFromFileDescriptorWriteBytes{{label_cluster_id}}[2m]))+sum(rate(tiflash_system_profile_event_PSMWriteBytes{{label_cluster_id}}[2m]))+sum(rate(tiflash_system_profile_event_WriteBufferAIOWriteBytes{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiFlash
  dashboard:

- name: TiFlash_full_remain_time:by_instance
  unit: "s"
  expr: 'label_replace(((sum(tiflash_system_current_metric_StoreSizeCapacity{{label_cluster_id}})by(instance)*0.8-sum(tiflash_system_current_metric_StoreSizeUsed{{label_cluster_id}})by(instance))/(sum(rate(tiflash_system_profile_event_WriteBufferFromFileDescriptorWriteBytes{{label_cluster_id}}[10m]))by(instance)+sum(rate(tiflash_system_profile_event_PSMWriteBytes{{label_cluster_id}}[10m]))by(instance)+sum(rate(tiflash_system_profile_event_WriteBufferAIOWriteBytes{{label_cluster_id}}[10m]))by(instance))),"name","$1","instance","(.*)")'
  component: TiFlash
  dashboard:

- name: PD_uptime:by_instance
  unit: "s"
  expr: 'label_replace((time()-process_start_time_seconds{{label_cluster_id},{label_component}=~"pd"}),"name","$1","instance","(.*)")'
  component: PD
  dashboard:
  - title: 'PD'
    id:
      cloud: 'Q6RuHYIWktidbcloudmaster/pd-cluster-clinic'
      op: 'Q6RuHYIWkclustermaster/pd-cluster-clinic'

- name: PD_CPU_usage:by_instance
  unit: "%"
  expr: 'label_replace(irate(process_cpu_seconds_total{{label_cluster_id},{label_component}=~".*pd.*"}[2m])*100,"name","$1","instance","(.*)")'
  component: PD
  dashboard:
  - title: 'PD'
    id:
      cloud: 'Q6RuHYIWktidbcloudmaster/pd-cluster-clinic'
      op: 'Q6RuHYIWkclustermaster/pd-cluster-clinic'

- name: PD_CPU_usage_delta:total
  unit: "%"
  expr: 'label_replace((max(irate(process_cpu_seconds_total{{label_cluster_id},{label_component}=~".*pd.*"}[2m]))-min(irate(process_cpu_seconds_total{{label_cluster_id},{label_component}=~".*pd.*"}[2m])))*100,"name","pd_cpu_delta","","")'
  component: PD
  dashboard:

- name: PD_CPU_usage_max:total
  unit: "%"
  expr: 'label_replace(max(irate(process_cpu_seconds_total{{label_cluster_id},{label_component}=~".*pd.*"}[2m]))*100,"name","pd_cpu_max","","")'
  component: PD
  dashboard:

- name: PD_memory_usage:by_instance
  unit: "Bytes"
  expr: 'label_replace(process_resident_memory_bytes{{label_cluster_id},{label_component}="pd"},"name","$1","instance","(.*)")'
  component: PD
  dashboard:
  - title: 'PD'
    id:
      cloud: 'Q6RuHYIWktidbcloudmaster/pd-cluster-clinic'
      op: 'Q6RuHYIWkclustermaster/pd-cluster-clinic'

- name: PD_count:total
  unit: "1"
  expr: 'label_replace(count(process_cpu_seconds_total{{label_cluster_id}, {label_component}="pd"} > 0) by ({label_component}),"name","pd_total","","")'
  component: PD
  dashboard:

- name: TiDB_count:total
  unit: "1"
  expr: 'label_replace(count(process_cpu_seconds_total{{label_cluster_id}, {label_component}="tidb"} > 0) by ({label_component}),"name","tidb_total","","")'
  component: TiDB
  dashboard:

- name: TiKV_count:total
  unit: "1"
  expr: 'label_replace(count(process_cpu_seconds_total{{label_cluster_id}, {label_component}="tikv"} > 0) by ({label_component}),"name","tikv_count","","")'
  component: TiKV
  dashboard:

- name: TiFlash_count:total
  unit: "1"
  expr: 'label_replace(count(tiflash_proxy_process_cpu_seconds_total{{label_cluster_id}, {label_component}="tiflash"} > 0),"name","tiflash_count","","")'
  component: TiFlash
  dashboard:

# Unclassified
- name: KV_Request_Time:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_tikvclient_request_time_counter{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'Performance-Overview'
    id: 
      cloud: 'eDbRZpnWatidbcloudmaster/performance-overview-cluster-clinic'
      op: 'eDbRZpnWaclustermaster/performance-overview-cluster-clinic'

- name: KV_Request_Time:by_instance
  unit: "s"
  expr: 'label_replace(label_replace(label_replace(sum(rate(tidb_tikvclient_request_time_counter{{label_cluster_id}}[2m]))by(instance,type,source),"name1","$1","instance","(.*)"),"name2","$1","type","(.*)"),"name3","$1","source","(.*)")'
  component: TiDB
  dashboard:

- name: KV_backoff_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_tikvclient_backoff_seconds_sum{{label_cluster_id}}[2m]))/sum(rate(tidb_tikvclient_backoff_seconds_count{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: KV_backoff_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tidb_tikvclient_backoff_seconds_sum{{label_cluster_id}}[2m]))by(instance)/sum(rate(tidb_tikvclient_backoff_seconds_count{{label_cluster_id}}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: Coprocessor_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_sum{{label_cluster_id},type=~"coprocessor"}[2m]))/sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type=~"coprocessor"}[2m])),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: Coprocessor_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_sum{{label_cluster_id},type=~"coprocessor"}[2m]))by(instance)/sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type=~"coprocessor"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:

- name: Scan_total_versions:total
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_coprocessor_scan_details{{label_cluster_id},req!~"analyze.*|checksum.*",tag="next"}[2m])),"name","total","","")'
  component: TiKV
  dashboard:
  
- name: Scan_processed_keys:total
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_coprocessor_scan_details{{label_cluster_id},req!~"analyze.*|checksum.*",tag="processed_keys"}[2m])),"name","total","","")'
  component: TiKV
  dashboard:

- name: TiKV_pesslock_wait_time:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_lock_manager_waiter_lifetime_duration_sum{{label_cluster_id}}[2m]))by(instance)/sum(rate(tikv_lock_manager_waiter_lifetime_duration_count{{label_cluster_id}}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:

- name: TiKV_pesslock_wait_count:total
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_lock_manager_task_counter{{label_cluster_id},type="wait_for"}[2m])),"name","total","","")'
  component: TiKV
  dashboard:

- name: Copr_wait_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_coprocessor_request_wait_seconds_sum{{label_cluster_id}}[2m]))/sum(rate(tikv_coprocessor_request_wait_seconds_count{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: Copr_wait_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_coprocessor_request_wait_seconds_sum{{label_cluster_id}}[2m]))by(instance)/sum(rate(tikv_coprocessor_request_wait_seconds_count{{label_cluster_id}}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:

- name: Copr_handle_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_coprocessor_request_handle_seconds_sum{{label_cluster_id}}[2m]))/sum(rate(tikv_coprocessor_request_handle_seconds_count{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: Copr_handle_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_coprocessor_request_handle_seconds_sum{{label_cluster_id}}[2m]))by(instance)/sum(rate(tikv_coprocessor_request_handle_seconds_count{{label_cluster_id}}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:

- name: Small_read_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_sum{{label_cluster_id},type=~"coprocessor"}[2m]))/sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type=~"coprocessor"}[2m])),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Test-Cluster-TiKV-FastTune'
    id:
      cloud: 'TiKVFastTunetidbcloudmaster/tikv-fasttune-cluster-clinic'
      op: 'TiKVFastTuneclustermaster/tikv-fasttune-cluster-clinic'

- name: Small_read_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_sum{{label_cluster_id},type=~"kv_batch_get|kv_batch_get_command|kv_get|kv_scan"}[2m]))by(instance)/sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type=~"kv_batch_get|kv_batch_get_command|kv_get|kv_scan"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:

- name: Write_rpc_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_sum{type=~"kv_prewrite|kv_commit|kv_pessimistic_lock"}[2m]))/sum(rate(tikv_grpc_msg_duration_seconds_count{type=~"kv_prewrite|kv_commit|kv_pessimistic_lock"}[2m])),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'Test-Cluster-TiKV-FastTune'
    id:
      cloud: 'TiKVFastTunetidbcloudmaster/tikv-fasttune-cluster-clinic'
      op: 'TiKVFastTuneclustermaster/tikv-fasttune-cluster-clinic'

- name: Write_rpc_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_sum{{label_cluster_id},type=~"kv_prewrite|kv_commit|kv_pessimistic_lock"}[2m]))by(instance)/sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type=~"kv_prewrite|kv_commit|kv_pessimistic_lock"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:

- name: Latch_wait_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_scheduler_latch_wait_duration_seconds_sum{{label_cluster_id}}[2m]))/sum(rate(tikv_scheduler_latch_wait_duration_seconds_count{{label_cluster_id}}[2m])),"name","total","","")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: Latch_wait_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(tikv_scheduler_latch_wait_duration_seconds_sum{{label_cluster_id}}[2m]))by(instance)/sum(rate(tikv_scheduler_latch_wait_duration_seconds_count{{label_cluster_id}}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:

- name: TSO_rpc_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(pd_client_cmd_handle_cmds_duration_seconds_sum{{label_cluster_id},type="tso"}[2m]))by(instance)/sum(rate(pd_client_cmd_handle_cmds_duration_seconds_count{{label_cluster_id},type="tso"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: PD_grpc_duration:total
  unit: "s"
  expr: 'label_replace(sum(rate(pd_client_request_handle_requests_duration_seconds_sum{{label_cluster_id},type="tso"}[2m]))/sum(rate(pd_client_request_handle_requests_duration_seconds_count{{label_cluster_id},type="tso"}[2m])),"name","total","","")'
  component: TiDB
  dashboard:
  - title: 'TiDB-Details'
    id:
      cloud: '000000011tidbcloudmaster/tidb-cluster-clinic'
      op: '000000011clustermaster/tidb-cluster-clinic'

- name: PD_grpc_duration:by_instance
  unit: "s"
  expr: 'label_replace(sum(rate(pd_client_request_handle_requests_duration_seconds_sum{{label_cluster_id},type="tso"}[2m]))by(instance)/sum(rate(pd_client_request_handle_requests_duration_seconds_count{{label_cluster_id},type="tso"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiDB
  dashboard:

- name: gRPC:total
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id}}[2m])),"name","total_rpc","","")'
  component: TiKV
  dashboard:
  - title: 'Test-Cluster-TiKV-FastTune'
    id:
      cloud: 'TiKVFastTunetidbcloudmaster/tikv-fasttune-cluster-clinic'
      op: 'TiKVFastTuneclustermaster/tikv-fasttune-cluster-clinic'

- name: gRPC:by_type
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id}}[2m]))by(type),"name","$1","type","(.*)")'
  component: TiKV
  dashboard:
  - title: 'Test-Cluster-TiKV-FastTune'
    id:
      cloud: 'TiKVFastTunetidbcloudmaster/tikv-fasttune-cluster-clinic'
      op: 'TiKVFastTuneclustermaster/tikv-fasttune-cluster-clinic'

- name: Write-rpc:total
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type=~"kv_prewrite|kv_commit|kv_pessimistic_lock"}[2m])),"name","write_rpc","","")'
  component: TiKV
  dashboard:
  - title: 'Test-Cluster-TiKV-FastTune'
    id:
      cloud: 'TiKVFastTunetidbcloudmaster/tikv-fasttune-cluster-clinic'
      op: 'TiKVFastTuneclustermaster/tikv-fasttune-cluster-clinic'

- name: Smallread-rpc:total
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type=~"kv_get|kv_scan|kv_batch_get|kv_batch_get_command"}[2m])),"name","smallread_rpc","","")'
  component: TiKV
  dashboard:
  - title: 'Test-Cluster-TiKV-FastTune'
    id:  
      cloud: 'TiKVFastTunetidbcloudmaster/tikv-fasttune-cluster-clinic'
      op: 'TiKVFastTuneclustermaster/tikv-fasttune-cluster-clinic'

- name: Copr-rpc:total
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type="coprocessor"}[2m])),"name","copr_rpc","","")'
  component: TiKV
  dashboard:
  - title: 'Test-Cluster-TiKV-FastTune'
    id:
      cloud: 'TiKVFastTunetidbcloudmaster/tikv-fasttune-cluster-clinic'
      op: 'TiKVFastTuneclustermaster/tikv-fasttune-cluster-clinic'

- name: Read-rpc:total
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type=~"kv_get|kv_scan|kv_batch_get|kv_batch_get_command|coprocessor"}[2m])),"name","read_rpc","","")'
  component: TiKV
  dashboard:
  - title: 'Test-Cluster-TiKV-FastTune'
    id:
      cloud: 'TiKVFastTunetidbcloudmaster/tikv-fasttune-cluster-clinic'
      op: 'TiKVFastTuneclustermaster/tikv-fasttune-cluster-clinic'

- name: Read-rpc:by_instance
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type=~"kv_get|kv_scan|kv_batch_get|kv_batch_get_command|coprocessor"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:
  - title: 'Test-Cluster-TiKV-FastTune'
    id:
      cloud: 'TiKVFastTunetidbcloudmaster/tikv-fasttune-cluster-clinic'
      op: 'TiKVFastTuneclustermaster/tikv-fasttune-cluster-clinic'

- name: Write-rpc:by_instance
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type=~"kv_prewrite|kv_commit|kv_pessimistic_lock"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:
  - title: 'Test-Cluster-TiKV-FastTune'
    id:
      cloud: 'TiKVFastTunetidbcloudmaster/tikv-fasttune-cluster-clinic'
      op: 'TiKVFastTuneclustermaster/tikv-fasttune-cluster-clinic'

- name: Read-rpc:by_type
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type=~"kv_get|kv_scan|kv_batch_get|kv_batch_get_command|coprocessor"}[2m]))by(type),"name","$1","type","(.*)")'
  component: TiKV
  dashboard:
  - title: 'Test-Cluster-TiKV-FastTune'
    id:
      cloud: 'TiKVFastTunetidbcloudmaster/tikv-fasttune-cluster-clinic'
      op: 'TiKVFastTuneclustermaster/tikv-fasttune-cluster-clinic'

- name: Write-rpc:by_type
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type=~"kv_prewrite|kv_commit|kv_pessimistic_lock"}[2m]))by(type),"name","$1","type","(.*)")'
  component: TiKV
  dashboard:
  - title: 'Test-Cluster-TiKV-FastTune'
    id:
      cloud: 'TiKVFastTunetidbcloudmaster/tikv-fasttune-cluster-clinic'
      op: 'TiKVFastTuneclustermaster/tikv-fasttune-cluster-clinic'

- name: Copr-rpc:by_instance
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type="coprocessor"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:
  - title: 'Test-Cluster-TiKV-FastTune'
    id:
      cloud: 'TiKVFastTunetidbcloudmaster/tikv-fasttune-cluster-clinic'
      op: 'TiKVFastTuneclustermaster/tikv-fasttune-cluster-clinic'

- name: Small-read-rpc:by_instance
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_grpc_msg_duration_seconds_count{{label_cluster_id},type=~"kv_get|kv_scan|kv_batch_get|kv_batch_get_command"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:
  - title: 'Test-Cluster-TiKV-FastTune'
    id:
      cloud: 'TiKVFastTunetidbcloudmaster/tikv-fasttune-cluster-clinic'
      op: 'TiKVFastTuneclustermaster/tikv-fasttune-cluster-clinic'
  
- name: TiKV_region_size:total
  unit: "Bytes"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tikv_raftstore_region_size_bucket{{label_cluster_id}}[2m]))by(le)),"name","tikv_region_size","","")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: TiKV_safepoint:total
  unit: "s"
  expr: 'label_replace(max(tikv_gcworker_autogc_safe_point{{label_cluster_id}})/(2^18),"name","tikv_safepoint","","")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: TiKV_safepoint:by_instance
  unit: "s"
  expr: 'label_replace(max(tikv_gcworker_autogc_safe_point{{label_cluster_id}})by(instance)/(2^18),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: PD_schedulers
  unit: "1"
  expr: 'label_replace(pd_scheduler_status{{label_cluster_id},type="allow"},"name","$1","kind","(.*)")'
  component: PD
  dashboard:
  - title: 'PD'
    id:
      cloud: 'Q6RuHYIWktidbcloudmaster/pd-cluster-clinic'
      op: 'Q6RuHYIWkclustermaster/pd-cluster-clinic'

- name: Raft-engine:total
  unit: "1"
  expr: 'label_replace(sum(rate(raft_engine_write_apply_duration_seconds_count{{label_cluster_id},instance=~".*"}[2m])),"name","raft_engine","","")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: Asyncio_cpu:total
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_thread_cpu_seconds_total{{label_cluster_id},name=~"store_write.*"}[2m])),"name","asyncio_cpu_total","","")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: Asyncio_cpu:by_instance
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_thread_cpu_seconds_total{{label_cluster_id},name=~"store_write.*"}[2m]))by(instance),"name","$1","instance","(.*)")'
  component: TiKV
  dashboard:

- name: Raft_messages:by_type
  unit: "1"
  expr: 'label_replace(sum(rate(tikv_raftstore_raft_sent_message_total{{label_cluster_id}}[2m]))by(type),"name","$1","type","(.*)")'
  component: TiKV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'

- name: TiKV_raft_propose_wait:by_instance
  unit: "s"
  expr: 'label_replace(histogram_quantile(0.99,sum(rate(tikv_raftstore_request_wait_time_duration_secs_bucket{{label_cluster_id}}[2m]))by(le,instance)),"name","$1","instance","(.*)")'
  component: TikV
  dashboard:
  - title: 'TiKV-Details'
    id:
      cloud: 'RDVQiEzZztidbcloudmaster/tikv-details-cluster-clinic'
      op: 'RDVQiEzZzclustermaster/tikv-details-cluster-clinic'
