概要

Cloudflare と統合することで、Web トラフィック、DNS クエリ、脅威に関するインサイトなど、ゾーンのメトリクスを取得できます。インテグレーションは、Cloudflare の分析 API を通じて行われます。

セットアップ

作業を開始するには、Datadog アカウント のほか、API キーCloudflare Logpush へのアクセス権が必要です。なお、Logpush へのアクセスには、Enterprise アカウントプランの購入が必要です。

Cloudflare API トークンを使用する場合は、Zone > Zone > Read および Zone > Analytics > Read の権限を保有していることを確認してください。

インストール

Datadog の Cloudflare インテグレーションタイル を使用して、インテグレーションをインストールします。

コンフィギュレーション

  1. Datadog Cloudflare インテグレーションタイル 内の Configuration タブに移動します。
  2. 監視するアカウントの電子メールアドレスと、API キーまたはトークンを入力します。Cloudflare API キーと API トークンは、Cloudflare アカウントの My profile > Api Tokens の下にあります。
  3. アカウントの名前を追加します。この名前は任意で、メトリクスの account タグ内で使用されます。

ログの収集

Cloudflareでは、Cloudflare Logpush を使用してログを直接 Datadog にプッシュすることができます。Logpush のジョブは Cloudflare API または Cloudflare ダッシュボード で管理できます。

Cloudflare インテグレーションパイプラインをインストールすると、特定の属性が自動的にリマップされます。どの属性がリマップされるかを確認するには

  1. ログパイプライン に移動します。
  2. 右上の Browse Pipeline Library をクリックします。
  3. 検索バーに Cloudflare と入力します。
  4. Cloudflare をクリックすると、インストールされているリマッパーなどのプロセッサーのリストが表示されます。

Cloudflare API

  1. Logpush ジョブエンドポイントへ POST をリクエストし、Logpush ジョブを作成します。以下のフィールドを含めます。

    • name (任意): ドメイン名をジョブ名として使用。
    • destination_conf: 以下のパラメーターからなるログの出力先。
      • <DATADOG_ENDPOINT_URL>: Datadog HTTP ログのインテークエンドポイント。エンドポイントは、http-intake.logs./v1/input になります
      • <DATADOG_API_KEY>: 使用する Datadog API キー。
      • ddsource: cloudflare に設定。
      • service (任意): サービス名を指定。
      • host (任意): ホスト名を指定。
      • ddtags (任意): タグを指定。
    • dataset: 受信するログのカテゴリー。サポートされるデータセットについては、Cloudflare のログフィールド を参照。
    • logpull_options (オプション): フィールド、サンプルレート、タイムスタンプの形式を構成するには、Logpush API オプション を参照。

    リクエスト例:

    curl -s -X POST 'https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/logpush/jobs' \
    --header 'X-Auth-Key: <CLOUDFLARE_AUTH_KEY>' \
    --header 'X-Auth-Email: <CLOUDFLARE_AUTH_EMAIL>' \
    --header 'Content-Type: application/json' \
    --data-raw '{
       "name": "<NAME>",
       "destination_conf": "datadog://<DATADOG_ENDPOINT_URL>?header_DD-API-KEY=<DATADOG_API_KEY>&ddsource=cloudflare&service=cloudflare&ddtags=env:dev",
       "logpull_options": "fields=RayID,EdgeStartTimestamp&timestamps=rfc3339",
       "dataset": "http_requests"
    }'
    

    応答例:

    {
     "errors": [],
     "messages": [],
     "result": {
       "id": 100,
       "dataset": "http_requests",
       "enabled": false,
       "name": "<DOMAIN_NAME>",
       "logpull_options": "fields=RayID,EdgeStartTimestamp&timestamps=rfc3339",
       "destination_conf": "datadog://http-intake.logs./v1/input?header_DD-API-KEY=<DD-API-KEY>&ddsource=cloudflare&service=cloudflare&ddtags=env:dev",
       "last_complete": null,
       "last_error": null,
       "error_message": null
     },
     "success": true
    }
    

    id の値をメモしておきます。上記の例では、100 です。

  2. ジョブを有効にします。応答で返されたジョブ ID を使用してリクエスト本文で {"enabled": true} を送信します。

    リクエスト例:

    curl -s -X PUT \
    https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/logpush/jobs/<JOB_ID> -d'{"enabled":true}' | jq .
    

    応答例:

    {
      "errors": [],
      "messages": [],
      "result": {
        "id": 100,
        "dataset": "http_requests",
        "enabled": true,
        "name": "<DOMAIN_NAME>",
        "logpull_options": "fields=RayID,EdgeStartTimestamp&timestamps=rfc3339",
        "destination_conf": "datadog://?header_DD-API-KEY=<DATADOG-API-KEY>",
        "last_complete": null,
        "last_error": null,
        "error_message": null
      },
      "success": true
    }
    

Cloudflare ダッシュボード

  1. Cloudflare ダッシュボードの Logpush セクションでサービスを接続したら、データセットとデータフィールドを選択し、宛先として Datadog を選択します。

  2. Enter destination information の下で Datadog の URL エンドポイントを入力します。

    http-intake.logs./v1/input?ddsource=cloudflare
    

    : ddsource=cloudflare は必須です。ログを区別するために、オプションで servicehostddtags などのパラメーターを追加することもできます。

    :

    http-intake.logs./v1/input?service=<SERVICE>&host=<HOST>&ddsource=cloudflare
    
  3. Datadog Cloudflare インテグレーションタイルのセットアップに使用した Datadog API キーを入力します。

  4. アクセスを確認すると、Prove ownership の下に “Ready to push!” と表示されます。Push をクリックして完了します。

収集データ

メトリクス

cloudflare.requests.all
(count)
Total request count
Shown as request
cloudflare.requests.cached
(count)
Cached requests count
Shown as request
cloudflare.requests.uncached
(count)
Uncached requests count
Shown as request
cloudflare.requests.ssl.encrypted
(count)
SSL encrypted requests count
Shown as request
cloudflare.requests.ssl.unencrypted
(count)
Unencrypted requests count
Shown as request
cloudflare.requests.country
(count)
Request count, tagged by IATA country code
Shown as request
cloudflare.requests.status
(count)
Request count, tagged by HTTP response code
Shown as request
cloudflare.requests.content_type
(count)
Request count, tagged by Content-Type
Shown as request
cloudflare.requests.ip_class
(count)
Request count, tagged by IP class
Shown as request
cloudflare.bandwidth.all
(count)
Total bandwidth
Shown as byte
cloudflare.bandwidth.cached
(count)
Cached bandwidth
Shown as byte
cloudflare.bandwidth.uncached
(count)
Uncached bandwidth
Shown as byte
cloudflare.bandwidth.ssl.encrypted
(count)
SSL encrypted bandwidth
Shown as byte
cloudflare.bandwidth.ssl.unencrypted
(count)
Unencrypted bandwidth
Shown as byte
cloudflare.bandwidth.country
(count)
Bandwidth tagged by IATA country code
Shown as byte
cloudflare.bandwidth.content_type
(count)
Bandwidth tagged by Content-Type
Shown as byte
cloudflare.threats.all
(count)
Total threats
Shown as operation
cloudflare.threats.type
(count)
Threats tagged by type
Shown as operation
cloudflare.threats.country
(count)
Threats tagged by IATA country code
Shown as operation
cloudflare.pageviews.all
(count)
Total page views
Shown as page
cloudflare.pageviews.search_engine
(count)
Page views tagged by search engine
Shown as page
cloudflare.uniques.all
(count)
Unique visitors count
Shown as connection
cloudflare.dns.query.all
(count)
DNS query count
Shown as request
cloudflare.dns.query.uncached
(count)
Uncached DNS query count
Shown as request
cloudflare.dns.query.stale
(count)
Stale DNS query count
Shown as request
cloudflare.dns.response_time.avg
(gauge)
DNS query average response time
Shown as millisecond
cloudflare.dns.response_time.median
(gauge)
DNS query median response time
Shown as millisecond
cloudflare.dns.response_time.90p
(gauge)
DNS query response time to the 90th percentile
Shown as millisecond
cloudflare.dns.response_time.99p
(gauge)
DNS query response time to the 99th percentile
Shown as millisecond
cloudflare.workers.requests.all
(count)
The request count to the worker script (metrics may not show without enabled API Key permissions)
Shown as request
cloudflare.workers.requests.errors
(count)
The error count to the worker script (metrics may not show without enabled API Key permissions)
Shown as request
cloudflare.workers.requests.subrequests
(count)
The subrequest count to the worker script (metrics may not show without enabled API Key permissions)
Shown as request
cloudflare.workers.response_time.75p
(gauge)
The worker response time to the 75th percentile (metrics may not show without enabled API Key permissions)
Shown as microsecond
cloudflare.workers.response_time.99p
(gauge)
The worker response time to the 99th percentile (metrics may not show without enabled API Key permissions)
Shown as microsecond
cloudflare.load_balancer.pool.round_trip_time.average
(gauge)
The average round trip time to reach the load balancer pool
Shown as millisecond
cloudflare.load_balancer.pool.health.status
(count)
The load balancer pool health status
Shown as request

アクセス許可

Cloudflare API トークンでこれらのアクセス許可が有効になっていることを確認します。

スコープアクセス許可ステータス
アカウントアカウント分析読み取り
アカウントアカウント設定読み取り
アカウントワーカースクリプト読み取り
ZoneZone読み取り
Zone分析読み取り
Zoneワーカールート読み取り
Zoneロードバランサー読み取り

イベント

Cloudflare インテグレーションには、イベントは含まれません。

サービスのチェック

Cloudflare インテグレーションには、サービスのチェック機能は含まれません。

トラブルシューティング

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