[comment]: <> (Code generated by mdatagen. DO NOT EDIT.)

# metadb

## Metrics

These are the metrics available for this scraper.

| Name | Description | Unit | Type | Attributes |
| ---- | ----------- | ---- | ---- | ---------- |
| **tidb_cloud.db_active_connections** | The number of active connection. | 1 | Gauge(Double) | <ul> <li>cluster_name</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.db_average_query_duration** | 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. | s | Gauge(Double) | <ul> <li>sql_type</li> <li>cluster_name</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.db_command_per_second** | The number of commands processed by TiDB per second, which is classified according to the success or failure of command execution results. | 1 | Gauge(Double) | <ul> <li>error_type</li> <li>cluster_name</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.db_connections** | Current number of connections in TiDB server. | 1 | Gauge(Int) | <ul> <li>cluster_name</li> <li>instance</li> <li>cluster_id</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.db_database_time** | A time model statistic that is the sum of all process' CPU consumption plus the sum of non-idle wait time. | s | Gauge(Double) | <ul> <li>sql_type</li> <li>cluster_name</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.db_disconnections** | The number of clients disconnected. | 1 | Gauge(Double) | <ul> <li>result</li> <li>cluster_name</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.db_failed_queries** | 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. | 1 | Gauge(Double) | <ul> <li>error_type</li> <li>cluster_name</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.db_failed_queries_total** | The total number of execution errors. | 1 | Sum(Int) | <ul> <li>error_type</li> <li>cluster_name</li> <li>cluster_id</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.db_queries_total** | The total number of queries. | 1 | Sum(Double) | <ul> <li>sql_type</li> <li>cluster_name</li> <li>cluster_id</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.db_queries_using_plan_cache_ops** | 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. | 1 | Gauge(Double) | <ul> <li>cluster_name</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.db_query_duration_seconds** | Query duration distribution of seconds. | s | Histogram | <ul> <li>sql_type</li> <li>cluster_name</li> <li>cluster_id</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.db_query_per_second** | 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. | 1 | Gauge(Double) | <ul> <li>error_type</li> <li>cluster_name</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.db_total_connection** | The number of current connection | 1 | Gauge(Double) | <ul> <li>cluster_name</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.db_transaction_per_second** | The number of transactions executed per second. | 1 | Gauge(Double) | <ul> <li>txn_mode</li> <li>error_type</li> <li>cluster_name</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.node_cpu_capacity_cores** | The capacity cores of TiDB/TiKV/TiFlash nodes. | 1 | Gauge(Double) | <ul> <li>cluster_name</li> <li>cluster_id</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.node_cpu_seconds_total** | The CPU usage of TiDB/TiKV/TiFlash nodes. | s | Sum(Int) | <ul> <li>cluster_name</li> <li>cluster_id</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.node_memory_capacity_bytes** | The memory capacity bytes of TiDB/TiKV/TiFlash nodes. | By | Gauge(Int) | <ul> <li>cluster_name</li> <li>cluster_id</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.node_memory_used_bytes** | The used memory bytes of TiDB/TiKV/TiFlash nodes. | By | Gauge(Double) | <ul> <li>cluster_name</li> <li>cluster_id</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.node_storage_capacity_bytes** | The disk capacity bytes of TiKV/TiFlash nodes. | By | Gauge(Int) | <ul> <li>cluster_name</li> <li>cluster_id</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |
| **tidb_cloud.node_storage_used_bytes** | The disk usage bytes of TiKV/TiFlash nodes. | By | Gauge(Int) | <ul> <li>cluster_name</li> <li>cluster_id</li> <li>instance</li> <li>component</li> <li>project_name</li> </ul> |

**Highlighted metrics** are emitted by default.

## Metric attributes

| Name | Description | Values |
| ---- | ----------- | ------ |
| cluster_id | Cluster ID. |  |
| cluster_name | Cluster name. |  |
| component | Components of a TiDB cluster. | tidb, tikv, pd, tiflash |
| error_type (type) | Error types of query errors, such as planner:xxx, executor:2345, etc. |  |
| in_txn | In transaction. |  |
| instance | Instance name. |  |
| project_name | Project name. |  |
| result | Result of disconnection. |  |
| sql_type | The command types of sql statements, such as select, create, etc. |  |
| txn_mode | Transaction mode. |  |
