name: metadb

attributes:
  sql_type:
    description: The command types of sql statements, such as select, create, etc.
  cluster_name:
    description: Cluster name.
  cluster_id:
    description: Cluster ID.
  instance:
    description: Instance name.
  component:
    description: Components of a TiDB cluster.
    enum: [tidb, tikv, pd, tiflash]
  error_type:
    value: type
    description: Error types of query errors, such as planner:xxx, executor:2345, etc.
  result:
    description: Result of disconnection.
  in_txn:
    description: In transaction.
  txn_mode:
    description: Transaction mode.
  project_name:
    description: Project name.

metrics:
  tidb_cloud.db_queries_total:
    enabled: true
    description: The total number of queries.
    unit: 1
    sum:
      value_type: double
      monotonic: true
      aggregation: cumulative
    attributes: [sql_type, cluster_name, cluster_id, instance, component, project_name]
  tidb_cloud.db_failed_queries_total:
    enabled: true
    description: The total number of execution errors.
    unit: 1
    sum:
      value_type: int
      monotonic: true
      aggregation: cumulative
    attributes: [error_type, cluster_name, cluster_id, instance, component, project_name]
  tidb_cloud.db_connections:
    enabled: true
    description: Current number of connections in TiDB server.
    unit: 1
    gauge:
      value_type: int
    attributes: [cluster_name, instance, cluster_id, component, project_name]
  tidb_cloud.db_query_duration_seconds:
    enabled: true
    description: Query duration distribution of seconds.
    unit: s
    histogram:
      aggregation: cumulative
    attributes: [sql_type, cluster_name, cluster_id, instance, component, project_name]
  tidb_cloud.db_total_connection:
    enabled: true
    description: The number of current connection
    unit: 1
    gauge:
      value_type: double
    attributes: [cluster_name, instance, component, project_name]
  tidb_cloud.db_active_connections:
    enabled: true
    description: The number of active connection.
    unit: 1
    gauge:
      value_type: double
    attributes: [cluster_name, instance, component, project_name]
  tidb_cloud.db_disconnections:
    enabled: true
    description: The number of clients disconnected.
    unit: 1
    gauge:
      value_type: double
    attributes: [result, cluster_name, instance, component, project_name]
  tidb_cloud.db_database_time:
    enabled: true
    description: A time model statistic that is the sum of all process' CPU consumption plus the sum of non-idle wait time.
    unit: s
    gauge:
      value_type: double
    attributes: [sql_type, cluster_name, instance, component, project_name]
  tidb_cloud.db_query_per_second:
    enabled: true
    description: The number of SQL statements executed per second on all TiDB instances, which is counted according to SELECT, INSERT, UPDATE, and other types of statements.
    unit: 1
    gauge:
      value_type: double
    attributes: [error_type, cluster_name, instance, component, project_name]
  tidb_cloud.db_failed_queries:
    enabled: true
    description: The statistics of error types (such as syntax errors and primary key conflicts) according to the errors occurred when executing SQL statements per second on each TiDB instance.
    unit: 1
    gauge:
      value_type: double
    attributes: [error_type, cluster_name, instance, component, project_name]
  tidb_cloud.db_command_per_second:
    enabled: true
    description: The number of commands processed by TiDB per second, which is classified according to the success or failure of command execution results.
    unit: 1
    gauge:
      value_type: double
    attributes: [error_type, cluster_name, instance, component, project_name]
  tidb_cloud.db_queries_using_plan_cache_ops:
    enabled: true
    description:
      "The statistics of queries using Plan Cache per second.\\n
The execution plan cache only supports the prepared statement command. If the value is 0, the execution plan cache has not been hit."
    unit: 1
    gauge:
      value_type: double
    attributes: [cluster_name, instance, component, project_name]
  tidb_cloud.db_average_query_duration:
    enabled: true
    description:
      "The duration between the time that the client's network request is sent to TiDB and the time that the request is returned to the client after TiDB has executed it. In general, client requests are sent in the form of SQL statements, but can also include the execution time of commands such as COM_PING, COM_SLEEP, COM_STMT_FETCH, and COM_SEND_LONG_DATA.\\n
Because TiDB supports Multi-Query, it supports sending multiple SQL statements at one time, such as select 1; select 1; select 1;. In this case, the total execution time of this query includes the execution time of all SQL statements."
    unit: s
    gauge:
      value_type: double
    attributes: [sql_type, cluster_name, instance, component, project_name]
  tidb_cloud.db_transaction_per_second:
    enabled: true
    description: The number of transactions executed per second.
    unit: 1
    gauge:
      value_type: double
    attributes: [txn_mode, error_type, cluster_name, instance, component, project_name]



  tidb_cloud.node_storage_used_bytes:
    enabled: true
    description: The disk usage bytes of TiKV/TiFlash nodes.
    unit: By
    gauge:
      value_type: int
    attributes: [cluster_name, cluster_id, instance, component, project_name]
  tidb_cloud.node_storage_capacity_bytes:
    enabled: true
    description: The disk capacity bytes of TiKV/TiFlash nodes.
    unit: By
    gauge:
      value_type: int
    attributes: [cluster_name, cluster_id, instance, component, project_name]



  tidb_cloud.node_cpu_seconds_total:
    enabled: true
    description: The CPU usage of TiDB/TiKV/TiFlash nodes.
    unit: s
    sum:
      value_type: int
      monotonic: true
      aggregation: cumulative
    attributes: [cluster_name, cluster_id, instance, component, project_name]
  tidb_cloud.node_cpu_capacity_cores:
    enabled: true
    description: The capacity cores of TiDB/TiKV/TiFlash nodes.
    unit: 1
    gauge:
      value_type: double
    attributes: [cluster_name, cluster_id, instance, component, project_name]



  tidb_cloud.node_memory_used_bytes:
    enabled: true
    description: The used memory bytes of TiDB/TiKV/TiFlash nodes.
    unit: By
    gauge:
      value_type: double
    attributes: [cluster_name, cluster_id, instance, component, project_name]
  tidb_cloud.node_memory_capacity_bytes:
    enabled: true
    description: The memory capacity bytes of TiDB/TiKV/TiFlash nodes.
    unit: By
    gauge:
      value_type: int
    attributes: [cluster_name, cluster_id, instance, component, project_name]
