Supported OS Linux Mac OS Windows

インテグレーションバージョン2.1.0

概要

TiDB クラスターを Datadog に接続すると、以下のことができます。

  • クラスターの主要な TiDB メトリクスを収集する。
  • TiDB/TiKV/TiFlash ログやスロークエリログなど、クラスターのログを収集する。
  • 提供されたダッシュボードでクラスターのパフォーマンスを視覚化する。

:

計画と使用

インフラストラクチャーリスト

まず、Datadog Agent をダウンロードして起動します。

次に、TiDB チェックを手動でインストールします。指示は環境によって異なります

datadog-agent integration install -t datadog-tidb==<INTEGRATION_VERSION> を実行します。

ブラウザトラブルシューティング

メトリクスの収集
  1. 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
  1. Agent を再起動します
収集データ

Agent バージョン 6.0 以降で利用可能

  1. Datadog Agent で、ログの収集はデフォルトで無効になっています。以下のように、datadog.yaml ファイルでこれを有効にします。

    logs_enabled: true
    
  2. 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"
    

    クラスターのコンフィギュレーションに従って、pathservice を変更します。

    次のコマンドを使用して、すべてのログパスを表示します。

    # 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.>
    
  3. 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

metrics コンフィギュレーションオプションを使用して TiDB クラスターから追加のメトリクスを収集することが可能です。

ヘルプ

TiDB チェックには、イベントは含まれません。

ヘルプ

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 とメモリのメトリクスが提供されていません。

  • macOS で TiKV または TiFlash インスタンスを tiup playground で実行しています。
  • 新しい Apple M1 マシンで TiKV または TiFlash インスタンスを docker-compose upd で実行しています。

メトリクスが多すぎます

TiDB チェックでは、Datadog の distribution メトリクスタイプがデフォルトで有効になります。データのこの部分は非常に大きく、多くのリソースを消費する可能性があります。この動作は、tidb.yml ファイルで変更できます。

  • send_distribution_buckets: false

Since there are many important metrics in a TiDB クラスターには多くの重要なメトリクスがあるため、TiDB チェックはデフォルトで max_returned_metrics10000 に設定します。必要に応じて、tidb.yml ファイルで max_returned_metrics を減少できます。

  • max_returned_metrics: 1000

ご不明な点は、Datadog のサポートチームまでお問合せください。