TiDB クラスターを Datadog に接続すると、以下のことができます。
クラスターの主要な TiDB メトリクスを収集する。 TiDB/TiKV/TiFlash ログやスロークエリログなど、クラスターのログを収集する。 提供されたダッシュボードでクラスターのパフォーマンスを視覚化する。 注 :
まず、Datadog Agent をダウンロードして起動 します。
次に、TiDB チェックを手動でインストールします。指示は環境によって異なります 。
datadog-agent integration install -t datadog-tidb==<INTEGRATION_VERSION>
を実行します。
TiDB のパフォーマンスデータを収集するには、Agent のコンフィギュレーションディレクトリのルートにある conf.d/
フォルダーの tidb.d/conf.yaml
ファイルを編集します。使用可能なすべてのコンフィギュレーションオプションについては、サンプル tidb.d/conf.yaml を参照してください。 サンプル tidb.d/conf.yaml で構成されるのは、PD インスタンスのみです。TiDB クラスターのその他のインスタンスについては、手動で構成する必要があります。たとえば、、以下のようになります。
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
Copy
Agent を再起動します 。Agent バージョン 6.0 以降で利用可能
Datadog Agent で、ログの収集はデフォルトで無効になっています。以下のように、datadog.yaml
ファイルでこれを有効にします。
TiDB のログの収集を開始するには、次の構成ブロックを tidb.d/conf.yaml
ファイルに追加します。
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"
Copy
クラスターのコンフィギュレーションに従って、path
と service
を変更します。
次のコマンドを使用して、すべてのログパスを表示します。
# 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.>
Copy
Agent を再起動します 。
Agent の status サブコマンド を実行し、Checks セクションで tidb
を探します。
tidb_cluster.tidb_executor_statement_total (count)The total number of statements executedShown as execution tidb_cluster.tidb_server_execute_error_total (count)The total number of execution errorsShown as error tidb_cluster.tidb_server_connections (gauge)Current number of connections in TiDB serverShown as connection tidb_cluster.tidb_server_handle_query_duration_seconds.count (count)The total number of handled queries in serverShown as query tidb_cluster.tidb_server_handle_query_duration_seconds.sum (count)The sum of handled query duration in serverShown as second tidb_cluster.tikv_engine_size_bytes (gauge)The disk usage bytes of TiKV instancesShown as byte tidb_cluster.tikv_store_size_bytes (gauge)The disk capacity bytes of TiKV instancesShown as byte tidb_cluster.tikv_io_bytes (count)The io read/write bytes of TiKV instancesShown as byte tidb_cluster.tiflash_store_size_used_bytes (gauge)The disk usage bytes of TiFlash instancesShown as byte tidb_cluster.tiflash_store_size_capacity_bytes (gauge)The disk capacity bytes of TiFlash instancesShown as byte tidb_cluster.process_cpu_seconds_total (count)The cpu usage seconds of TiDB/TiKV/TiFlash instancesShown as second tidb_cluster.process_resident_memory_bytes (gauge)The resident memory bytes of TiDB/TiKV/TiFlash instancesShown as byte
metrics
コンフィギュレーションオプションを使用して TiDB クラスターから追加のメトリクスを収集することが可能です。
TiDB チェックには、イベントは含まれません。
tidb_cluster.prometheus.health Returns CRITICAL
if the Agent cannot fetch Prometheus metrics, otherwise returns OK
.Statuses: ok, critical
以下のケースで、 TiKV および TiFlash の CPU とメモリのメトリクスが提供されていません。
TiDB チェックでは、Datadog の distribution
メトリクスタイプがデフォルトで有効になります。データのこの部分は非常に大きく、多くのリソースを消費する可能性があります。この動作は、tidb.yml
ファイルで変更できます。
send_distribution_buckets: false
Since there are many important metrics in a TiDB クラスターには多くの重要なメトリクスがあるため、TiDB チェックはデフォルトで max_returned_metrics
を 10000
に設定します。必要に応じて、tidb.yml
ファイルで max_returned_metrics
を減少できます。
max_returned_metrics: 1000
ご不明な点は、Datadog のサポートチーム までお問合せください。