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 を探します。

収集データ

メトリクス

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

イベント

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

サービスチェック

トラブルシューティング

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 のサポートチームまでお問合せください。

PREVIEWING: may/embedded-workflows