集成 TiDB Cloud 与 New Relic
TiDB Cloud 支持与 New Relic 集成。你可以配置 TiDB Cloud,将你的 TiDB 集群的指标发送到 New Relic。之后,你可以直接在 New Relic 的仪表盘中查看这些指标。
New Relic 集成版本
自 2023 年 4 月 11 日起,TiDB Cloud 支持项目级 New Relic 集成(Beta)。自 2025 年 7 月 31 日起,TiDB Cloud 推出集群级 New Relic 集成(预览版)。自 2025 年 9 月 30 日起,集群级 New Relic 集成将正式发布(GA)。
- 集群级 New Relic 集成:如果在 2025 年 7 月 31 日前,你的组织内没有未删除的旧版项目级 Datadog 或 New Relic 集成,TiDB Cloud 将为你的组织提供集群级 New Relic 集成,以体验最新的增强功能。
- 旧版项目级 New Relic 集成(Beta):如果在 2025 年 7 月 31 日前,你的组织内至少有一个未删除的旧版项目级 Datadog 或 New Relic 集成,TiDB Cloud 会在项目级保留现有和新建的集成,以避免影响当前的仪表盘。请注意,旧版项目级 New Relic 集成将于 2025 年 10 月 31 日弃用。如果你的组织仍在使用这些旧版集成,请按照 迁移 Datadog 和 New Relic 集成 的指引,迁移到新的集群级集成,以最大程度减少对指标相关服务的影响。
前提条件
若要将 TiDB Cloud 与 New Relic 集成,你必须拥有一个 New Relic 账号,并创建一个
Ingest - License类型的 New Relic API key。如果你还没有 New Relic 账号,请在 这里 注册。
若要为 TiDB Cloud 设置第三方指标集成,你必须在 TiDB Cloud 中拥有
Organization Owner或Project Owner权限。若要通过提供的链接查看集成页面或访问已配置的仪表盘,你至少需要Project Viewer角色,以访问 TiDB Cloud 项目下的目标集群。
限制
你无法在 TiDB Cloud Starter 或 TiDB Cloud Essential 集群中使用 New Relic 集成。
当集群状态为 CREATING、RESTORING、PAUSED 或 RESUMING 时,New Relic 集成不可用。
当带有 New Relic 集成的集群被删除时,其关联的集成服务也会被移除。
操作步骤
步骤 1. 使用你的 New Relic API Key 集成
根据你的 New Relic 集成版本,访问集成页面的步骤有所不同。
在 TiDB Cloud 控制台中,进入你项目的 Clusters 页面,然后点击目标集群名称,进入其概览页面。
在左侧导航栏,点击 Settings > Integrations。
在 Integrations 页面,点击 Integration to New Relic。
输入你的 New Relic API key,并选择 New Relic 的站点。
点击 Test Integration。
- 如果测试成功,会显示 Confirm 按钮。
- 如果测试失败,会显示错误信息。请根据提示排查并重试集成。
点击 Confirm 完成集成。
在 TiDB Cloud 控制台中,使用左上角的下拉框切换到目标项目。
在左侧导航栏,点击 Project Settings > Integrations。
在 Integrations 页面,点击 Integration to New Relic (BETA)。
输入你的 New Relic API key,并选择 New Relic 的站点。
点击 Test Integration。
- 如果测试成功,会显示 Confirm 按钮。
- 如果测试失败,会显示错误信息。请根据提示排查并重试集成。
点击 Confirm 完成集成。
步骤 2. 在 New Relic 中添加 TiDB Cloud 仪表盘
根据你的 New Relic 集成版本,操作步骤有所不同。
在 New Relic 合并待处理的 PR 后,将会有新的 TiDB Cloud 仪表盘可用。在此之前,你可以通过以下步骤手动导入仪表盘:
准备新仪表盘的 JSON 文件。
在 这里 下载模板 JSON 文件。
在 JSON 文件的第 4 行添加
"permissions": "PUBLIC_READ_WRITE",如下所示:{ "name": "TiDB Cloud Dynamic Tracker", "description": null, "permissions": "PUBLIC_READ_WRITE", ... }在 JSON 文件的所有
"accountIds": []字段中,添加你的 New Relic 账号 ID。例如:
"accountIds": [ 1234567 ],
登录 New Relic,点击左侧导航栏的 Dashboards,然后点击右上角的 Import dashboard。
在弹出的对话框中,将准备好的 JSON 文件内容全部粘贴到文本区域,然后点击 Import dashboard。
查看预置仪表盘
在 TiDB Cloud 控制台中,进入 Integrations 页面。
在 New Relic 区域点击 Dashboard 链接,查看你的 TiDB 集群的预置仪表盘。
根据你的 New Relic 集成版本,执行以下操作之一:
- 对于集群级 New Relic 集成,点击 TiDB Cloud Dynamic Tracker 查看新仪表盘。
- 对于旧版项目级 New Relic 集成(Beta),点击 TiDB Cloud Monitoring 查看旧版仪表盘。
New Relic 可用指标
New Relic 会跟踪你的 TiDB 集群的以下指标。
| 指标名称 | 指标类型 | 标签 | 描述 |
|---|---|---|---|
| tidb_cloud.db_database_time | gauge | sql_type: Select|Insert|... cluster_name: <cluster name>instance: tidb-0|tidb-1… component: tidb | 每秒在 TiDB 中运行的所有 SQL 语句消耗的总时间,包括所有进程的 CPU 时间和非空闲等待时间。 |
| tidb_cloud.db_query_per_second | gauge | type: Select|Insert|... cluster_name: <cluster name>instance: tidb-0|tidb-1… component: tidb | 所有 TiDB 实例每秒执行的 SQL 语句数量,按 SELECT、INSERT、UPDATE 等语句类型统计。 |
| tidb_cloud.db_average_query_duration | gauge | sql_type: Select|Insert|... cluster_name: <cluster name>instance: tidb-0|tidb-1… component: tidb | 客户端网络请求发送到 TiDB 与 TiDB 执行后返回给客户端之间的耗时。 |
| tidb_cloud.db_failed_queries | gauge | type: executor:xxxx|parser:xxxx|... cluster_name: <cluster name>instance: tidb-0|tidb-1… component: tidb | 每秒每个 TiDB 实例发生的 SQL 执行错误,按错误类型(如语法错误、主键冲突等)统计。 |
| tidb_cloud.db_total_connection | gauge | cluster_name: <cluster name>instance: tidb-0|tidb-1… component: tidb | 当前 TiDB 服务器的连接数。 |
| tidb_cloud.db_active_connections | gauge | cluster_name: <cluster name>instance: tidb-0|tidb-1… component: tidb | 活跃连接数。 |
| tidb_cloud.db_disconnections | gauge | result: ok|error|undetermined cluster_name: <cluster name>instance: tidb-0|tidb-1… component: tidb | 断开连接的客户端数量。 |
| tidb_cloud.db_command_per_second | gauge | type: Query|StmtPrepare|... cluster_name: <cluster name>instance: tidb-0|tidb-1… component: tidb | TiDB 每秒处理的命令数,按命令执行结果的成功或失败分类。 |
| tidb_cloud.db_queries_using_plan_cache_ops | gauge | cluster_name: <cluster name>instance: tidb-0|tidb-1… component: tidb | 每秒使用 Plan Cache 的查询统计。执行计划缓存仅支持 prepared statement 命令。 |
| tidb_cloud.db_transaction_per_second | gauge | txn_mode: pessimistic|optimistic type: abort|commit|... cluster_name: <cluster name>instance: tidb-0|tidb-1… component: tidb | 每秒执行的事务数。 |
| tidb_cloud.node_storage_used_bytes | gauge | cluster_name: <cluster name>instance: tikv-0|tikv-1…|tiflash-0|tiflash-1… component: tikv|tiflash | TiKV/TiFlash 节点的磁盘使用量(字节)。 |
| tidb_cloud.node_storage_capacity_bytes | gauge | cluster_name: <cluster name>instance: tikv-0|tikv-1…|tiflash-0|tiflash-1… component: tikv|tiflash | TiKV/TiFlash 节点的磁盘容量(字节)。 |
| tidb_cloud.node_cpu_seconds_total (Beta only) | count | cluster_name: <cluster name>instance: tidb-0|tidb-1…|tikv-0…|tiflash-0… component: tidb|tikv|tiflash | TiDB/TiKV/TiFlash 节点的 CPU 使用量。 |
| tidb_cloud.node_cpu_capacity_cores | gauge | cluster_name: <cluster name>instance: tidb-0|tidb-1…|tikv-0…|tiflash-0… component: tidb|tikv|tiflash | TiDB/TiKV/TiFlash 节点的 CPU 核心数上限。 |
| tidb_cloud.node_memory_used_bytes | gauge | cluster_name: <cluster name>instance: tidb-0|tidb-1…|tikv-0…|tiflash-0… component: tidb|tikv|tiflash | TiDB/TiKV/TiFlash 节点已用内存(字节)。 |
| tidb_cloud.node_memory_capacity_bytes | gauge | cluster_name: <cluster name>instance: tidb-0|tidb-1…|tikv-0…|tiflash-0… component: tidb|tikv|tiflash | TiDB/TiKV/TiFlash 节点的内存容量(字节)。 |
对于集群级 New Relic 集成,还支持以下额外指标:
| 指标名称 | 指标类型 | 标签 | 描述 |
|---|---|---|---|
| tidb_cloud.node_storage_available_bytes | gauge | instance: tidb-0\|tidb-1\|...component: tikv\|tiflashcluster_name: <cluster name> | TiKV 或 TiFlash 节点可用磁盘空间(字节)。 |
| tidb_cloud.node_disk_read_latency | gauge | instance: tidb-0\|tidb-1\|...component: tikv\|tiflashcluster_name: <cluster name>device: nvme.*\|dm.* | 每个存储设备的读延迟(秒)。 |
| tidb_cloud.node_disk_write_latency | gauge | instance: tidb-0\|tidb-1\|...component: tikv\|tiflashcluster_name: <cluster name>device: nvme.*\|dm.* | 每个存储设备的写延迟(秒)。 |
| tidb_cloud.db_kv_request_duration | gauge | instance: tidb-0\|tidb-1\|...component: tikvcluster_name: <cluster name>type: BatchGet\|Commit\|Prewrite\|... | TiKV 按类型请求的耗时(秒)。 |
| tidb_cloud.db_component_uptime | gauge | instance: tidb-0\|tidb-1\|...component: tidb\|tikv\|tiflashcluster_name: <cluster name> | TiDB 组件的运行时长(秒)。 |
| tidb_cloud.cdc_changefeed_latency (AKA cdc_changefeed_checkpoint_ts_lag) | gauge | changefeed_id: <changefeed-id>cluster_name: <cluster name> | changefeed owner 的 checkpoint timestamp 延迟(秒)。 |
| tidb_cloud.cdc_changefeed_resolved_ts_lag | gauge | changefeed_id: <changefeed-id>cluster_name: <cluster name> | changefeed owner 的 resolved timestamp 延迟(秒)。 |
| tidb_cloud.cdc_changefeed_status | gauge | changefeed_id: <changefeed-id>cluster_name: <cluster name> | Changefeed 状态:-1: Unknown0: Normal1: Warning2: Failed3: Stopped4: Finished6: Warning7: Other |
| tidb_cloud.resource_manager_resource_unit_read_request_unit | gauge | cluster_name: <cluster name>resource_group: <group-name> | Resource Manager 消耗的读请求单元(RU)。 |
| tidb_cloud.resource_manager_resource_unit_write_request_unit | gauge | cluster_name: <cluster name>resource_group: <group-name> | Resource Manager 消耗的写请求单元(RU)。 |
| tidb_cloud.dm_task_state | gauge | instance: instancetask: taskcluster_name: <cluster name> | 数据迁移任务状态:0: Invalid1: New2: Running3: Paused4: Stopped5: Finished15: Error |
| tidb_cloud.dm_syncer_replication_lag_bucket | gauge | instance: instancecluster_name: <cluster name> | 数据迁移的复制延迟(bucket)。 |
| tidb_cloud.dm_syncer_replication_lag_gauge | gauge | instance: instancetask: taskcluster_name: <cluster name> | 数据迁移的复制延迟(gauge)。 |
| tidb_cloud.dm_relay_read_error_count | gauge | instance: instancecluster_name: <cluster name> | 从主库读取 binlog 失败次数。 |
| tidb_cloud.node_memory_available_bytes | gauge | cluster_name: <cluster name>instance: tidb-0|tidb-1…|tikv-0…|tiflash-0… component: tidb|tikv|tiflash | TiDB/TiKV/TiFlash 节点可用内存(字节)。 |
| tidb_cloud.cdc_changefeed_replica_rows | gauge | changefeed_id: <changefeed-id>cluster_name: <cluster name> | TiCDC 节点每秒写入下游的事件数。 |
| tidb_cloud.node_cpu_seconds_total_rate | gauge | cluster_name: <cluster name>instance: tidb-0|tidb-1…|tikv-0…|tiflash-0… component: tidb|tikv|tiflash | TiDB/TiKV/TiFlash 节点的 CPU 使用率。 |