To find out if this integration is available in your organization, see your Datadog Integrations page or ask your organization administrator.
To initiate an exception request to enable this integration for your organization, email [email protected].
概要
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
- 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"
クラスターのコンフィギュレーションに従って、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.>
Agent を再起動します。
検証
Agent の status サブコマンドを実行し、Checks セクションで tidb を探します。
収集データ
メトリクス
| |
|---|
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.
metrics コンフィギュレーションオプションを使用して TiDB クラスターから追加のメトリクスを収集することが可能です。
イベント
TiDB チェックには、イベントは含まれません。
サービスチェック
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
トラブルシューティング
macOS で TiKV および TiFlash インスタンスに CPU とメモリのメトリクスがありません
以下のケースで、 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 のサポートチームまでお問合せください。