Versión de la integración2.1.0
Conecta el clúster TiDB a Datadog para:
- Recopilar métricas TiDB clave de tu clúster.
- Recopilar logs de tu clúster, como logs TiDB/TiKV/TiFlash y logs de consultas lentas.
- Visualizar el rendimiento del clúster en el dashboard proporcionado.
Nota:
Configuración
Instalación
En primer lugar, descarga e inicia el Datadog Agent.
A continuación, instala manualmente el check de TiDB. Las instrucciones varían en función del entorno.
Ejecuta datadog-agent integration install -t datadog-tidb==<INTEGRATION_VERSION>.
Configuración
Recopilación de métricas
- Edita el archivo
tidb.d/conf.yaml, que se encuentra en la carpeta conf.d/ en la raíz del directorio de configuración de tu Agent, para empezar a recopilar los datos de rendimiento de tu TiDB. Para conocer todas las opciones de configuración disponibles, consulta el tidb.d/conf.yaml de ejemplo.
El tidb.d/conf.yaml de ejemplo sólo configura la instancia PD. Es necesario configurar manualmente las otras instancias en el clúster TiDB así:
init_config:
instances:
- pd_metric_url: http://localhost:2379/metrics
send_distribution_buckets: true
tags:
- cluster_name:cluster01
- tidb_metric_url: http://localhost:10080/metrics
send_distribution_buckets: true
tags:
- cluster_name:cluster01
- tikv_metric_url: http://localhost:20180/metrics
send_distribution_buckets: true
tags:
- cluster_name:cluster01
- tiflash_metric_url: http://localhost:8234/metrics
send_distribution_buckets: true
tags:
- cluster_name:cluster01
- tiflash_proxy_metric_url: http://localhost:20292/metrics
send_distribution_buckets: true
tags:
- cluster_name:cluster01
- Reinicia el Agent.
Recopilación de logs
Disponible para la versión 6.0 o posteriores del Agent
La recopilación de logs se encuentra deshabilitada de manera predeterminada en el Datadog Agent. Habilítala en tu archivo datadog.yaml:
Añade este bloque de configuración a tu archivo tidb.d/conf.yaml para empezar a recopilar tus logs de TiDB:
logs:
# pd log
- type: file
path: "/tidb-deploy/pd-2379/log/pd*.log"
service: "tidb-cluster"
source: "pd"
# tikv log
- type: file
path: "/tidb-deploy/tikv-20160/log/tikv*.log"
service: "tidb-cluster"
source: "tikv"
# tidb log
- type: file
path: "/tidb-deploy/tidb-4000/log/tidb*.log"
service: "tidb-cluster"
source: "tidb"
exclude_paths:
- /tidb-deploy/tidb-4000/log/tidb_slow_query.log
- type: file
path: "/tidb-deploy/tidb-4000/log/tidb_slow_query*.log"
service: "tidb-cluster"
source: "tidb"
log_processing_rules:
- type: multi_line
name: new_log_start_with_datetime
pattern: '#\sTime:'
tags:
- "custom_format:tidb_slow_query"
# tiflash log
- type: file
path: "/tidb-deploy/tiflash-9000/log/tiflash*.log"
service: "tidb-cluster"
source: "tiflash"
Cambia la path y el service según la configuración de tu clúster.
Utiliza estos comandos para mostrar la ruta de todos los logs:
# show deploying directories
tiup cluster display <YOUR_CLUSTER_NAME>
# find specific logging file path by command arguments
ps -fwwp <TIDB_PROCESS_PID/PD_PROCESS_PID/etc.>
Reinicia el Agent.
Validación
Ejecuta el subcomando de estado del Agent y busca tidb en la sección Checks.
Datos recopilados
Métricas
| |
|---|
tidb_cluster.tidb_executor_statement_total (count) | The total number of statements executed Shown as execution |
tidb_cluster.tidb_server_execute_error_total (count) | The total number of execution errors Shown as error |
tidb_cluster.tidb_server_connections (gauge) | Current number of connections in TiDB server Shown as connection |
tidb_cluster.tidb_server_handle_query_duration_seconds.count (count) | The total number of handled queries in server Shown as query |
tidb_cluster.tidb_server_handle_query_duration_seconds.sum (count) | The sum of handled query duration in server Shown as second |
tidb_cluster.tikv_engine_size_bytes (gauge) | The disk usage bytes of TiKV instances Shown as byte |
tidb_cluster.tikv_store_size_bytes (gauge) | The disk capacity bytes of TiKV instances Shown as byte |
tidb_cluster.tikv_io_bytes (count) | The io read/write bytes of TiKV instances Shown as byte |
tidb_cluster.tiflash_store_size_used_bytes (gauge) | The disk usage bytes of TiFlash instances Shown as byte |
tidb_cluster.tiflash_store_size_capacity_bytes (gauge) | The disk capacity bytes of TiFlash instances Shown as byte |
tidb_cluster.process_cpu_seconds_total (count) | The cpu usage seconds of TiDB/TiKV/TiFlash instances Shown as second |
tidb_cluster.process_resident_memory_bytes (gauge) | The resident memory bytes of TiDB/TiKV/TiFlash instances Shown as byte |
It is possible to use the metrics configuration option to collect additional metrics from a TiDB cluster.
Es posible utilizar la opción de configuración metrics para recopilar métricas adicionales de un clúster TiDB.
Eventos
El check de TiDB no incluye eventos.
Checks de servicio
Service Checks are based on tidb_cluster.prometheus.health metrics. This check is controlled by the health_service_check config and default to true.
You can modify this behavior in tidb.yml file.
tidb_cluster.prometheus.health
Returns CRITICAL if the Agent cannot fetch Prometheus metrics, otherwise returns OK.
Statuses: ok, critical
Solucionar problemas
Faltan métricas de CPU y memoria para las instancias TiKV y TiFlash en macOS
Las métricas de CPU y memoria no se proporcionan para las instancias TiKV y TiFlash en los siguientes casos:
Demasiadas métricas
El check de TiDB habilita por defecto el tipo de métrica distribution de Datadog. Esta parte de los datos es bastante grande y puede consumir muchos recursos. Puedes modificar este comportamiento en el archivo tidb.yml:
send_distribution_buckets: false
Debido a que en un clúster TiDB hay muchas métricas, el check de TiDB define max_returned_metrics en 10000 por defecto. Si es necesario, puedes reducir max_returned_metrics en el archivo tidb.yml:
max_returned_metrics: 1000
¿Necesitas ayuda? Ponte en contacto con el servicio de asistencia de Datadog.