- 重要な情報
- はじめに
- 用語集
- ガイド
- エージェント
- インテグレーション
- OpenTelemetry
- 開発者
- API
- CoScreen
- アプリ内
- Service Management
- インフラストラクチャー
- アプリケーションパフォーマンス
- 継続的インテグレーション
- ログ管理
- セキュリティ
- UX モニタリング
- 管理
ログの収集には、Datadog Agent v6.0 以上が必要です。古いバージョンの Agent には、log collection
インターフェイスが含まれていません。まだ Agent を使用していない場合は、Agent のインストール手順に従ってください。
Datadog Agent では、ログの収集はデフォルトで有効になっていません。Agent を Kubernetes または Docker 環境で実行している場合は、専用の Kubernetes ログ収集または Docker ログ収集のドキュメントを参照してください。
ホストで実行されている Agent でログ収集を有効にするには、Agent のメインコンフィギュレーションファイル (datadog.yaml
) で logs_enabled: false
を logs_enabled: true
に変更します。
datadog.yaml
## @param logs_enabled - boolean - optional - default: false
## @env DD_LOGS_ENABLED - boolean - optional - default: false
## Enable Datadog Agent log collection by setting logs_enabled to true.
logs_enabled: false
## @param logs_config - custom object - optional
## Enter specific configurations for your Log collection.
## Uncomment this parameter and the one below to enable them.
## See https://docs.datadoghq.com/agent/logs/
logs_config:
## @param container_collect_all - boolean - optional - default: false
## @env DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL - boolean - optional - default: false
## Enable container log collection for all the containers (see ac_exclude to filter out containers)
container_collect_all: false
## @param logs_dd_url - string - optional
## @env DD_LOGS_CONFIG_DD_URL - string - optional
## Define the endpoint and port to hit when using a proxy for logs. The logs are forwarded in TCP
## therefore the proxy must be able to handle TCP connections.
logs_dd_url: <ENDPOINT>:<PORT>
## @param logs_no_ssl - boolean - optional - default: false
## @env DD_LOGS_CONFIG_LOGS_NO_SSL - optional - default: false
## Disable the SSL encryption. This parameter should only be used when logs are
## forwarded locally to a proxy. It is highly recommended to then handle the SSL encryption
## on the proxy side.
logs_no_ssl: false
## @param processing_rules - list of custom objects - optional
## @env DD_LOGS_CONFIG_PROCESSING_RULES - list of custom objects - optional
## Global processing rules that are applied to all logs. The available rules are
## "exclude_at_match", "include_at_match" and "mask_sequences". More information in Datadog documentation:
## https://docs.datadoghq.com/agent/logs/advanced_log_collection/#global-processing-rules
processing_rules:
- type: <RULE_TYPE>
name: <RULE_NAME>
pattern: <RULE_PATTERN>
## @param force_use_http - boolean - optional - default: false
## @env DD_LOGS_CONFIG_FORCE_USE_HTTP - boolean - optional - default: false
## By default, the Agent sends logs in HTTPS batches to port 443 if HTTPS connectivity can
## be established at Agent startup, and falls back to TCP otherwise. Set this parameter to `true` to
## always send logs with HTTPS (recommended).
force_use_http: true
## @param force_use_tcp - boolean - optional - default: false
## @env DD_LOGS_CONFIG_FORCE_USE_TCP - boolean - optional - default: false
## By default, logs are sent through HTTPS if possible, set this parameter
## to `true` to always send logs via TCP. If `use_http` is set to `true`, this parameter
## is ignored.
force_use_tcp: true
## @param use_compression - boolean - optional - default: false
## @env DD_LOGS_CONFIG_USE_COMPRESSION - boolean - optional - default: false
## This parameter is available when sending logs with HTTPS. If enabled, the Agent
## compresses logs before sending them.
use_compression: true
## @param compression_level - integer - optional - default: 6
## @env DD_LOGS_CONFIG_COMPRESSION_LEVEL - boolean - optional - default: false
## The compression_level parameter accepts values from 0 (no compression)
## to 9 (maximum compression but higher resource usage). Only takes effect if
## `use_compression` is set to `true`.
compression_level: 6
## @param batch_wait - integer - optional - default: 5
## @env DD_LOGS_CONFIG_BATCH_WAIT - integer - optional - default: 5
## The maximum time the Datadog Agent waits to fill each batch of logs before sending.
batch_wait: 5
## @param open_files_limit - integer - optional - default: 500
## @env DD_LOGS_CONFIG_OPEN_FILES_LIMIT - integer - optional - default: 500
## The maximum number of files that can be tailed in parallel.
## Note: the default for windows and Mac OS is 200. The default for
## all other systems is 500.
open_files_limit: 500
## @param file_wildcard_selection_mode - string - optional - default: `by_name`
## @env DD_LOGS_CONFIG_FILE_WILDCARD_SELECTION_MODE - string - optional - default: `by_name`
## The strategy used to prioritize wildcard matches if they exceed the open file limit.
##
## Choices are `by_name` and `by_modification_time`.
##
## `by_name` means that each log source is considered and the matching files are ordered
## in reverse name order. While there are less than `logs_config.open_files_limit` files
## being tailed, this process repeats, collecting from each configured source.
##
## `by_modification_time` takes all log sources and first adds any log sources that
## point to a specific file. Next, it finds matches for all wildcard sources.
## This resulting list is ordered by which files have been most recently modified
## and the top `logs_config.open_files_limit` most recently modified files are
## chosen for tailing.
##
## WARNING: `by_modification_time` is less performant than `by_name` and will trigger
## more disk I/O at the configured wildcard log paths.
file_wildcard_selection_mode: by_name
## @param max_message_size_bytes - integer - optional - default: 256000
## @env DD_LOGS_CONFIG_MAX_MESSAGE_SIZE_BYTES - integer - optional - default : 256000
## The maximum size of single log message in bytes. If maxMessageSizeBytes exceeds
## the documented API limit of 1MB - any payloads larger than 1MB will be dropped by the intake.
https://docs.datadoghq.com/api/latest/logs/
max_message_size_bytes: 256000
Agent v6.19+/v7.19+ 以降、使用されるデフォルトのトランスポートは HTTPS トランスポートです。HTTPS/TCP トランスポートを実行する方法の詳細については、Agent トランスポートのドキュメントを参照してください。
環境変数を伴った形でログを送信するには、以下の構成を行ってください。
DD_LOGS_ENABLED=true
ログ収集を有効にすると、Agent から Datadog にログを転送できるようになります。次に、Agent でログの収集元を設定します。
Datadog Agent v6 は、収集したログをファイル、ネットワーク (TCP または UDP)、journald、Windows チャンネルから Datadog に転送できます。
conf.d/
ディレクトリに、Datadog ユーザーがアクセスできる新しい <CUSTOM_LOG_SOURCE>.d/
フォルダを作成します。conf.yaml
ファイルを作成します。<CUSTOM_LOG_SOURCE>
を検索します。権限エラーがある場合は、ログファイルを追跡する権限の問題を参照してトラブルシューティングを行ってください。
以下に、カスタムログ収集設定の例を示します。
<PATH_LOG_FILE>/<LOG_FILE_NAME>.log
に保存されているログを <APP_NAME>
アプリケーションから収集するには、Agent の構成ディレクトリのルートに以下の内容の <APP_NAME>.d/conf.yaml
ファイルを作成します。
logs:
- type: file
path: "<PATH_LOG_FILE>/<LOG_FILE_NAME>.log"
service: "<APP_NAME>"
source: "<SOURCE>"
Windows では、パス <DRIVE_LETTER>:\<PATH_LOG_FILE>\<LOG_FILE_NAME>.log
を使用し、ユーザー ddagentuser
がログファイルへの読み取りおよび書き込みアクセス権を持つことを確認します。
TCP ポート 10518 にログを転送する <APP_NAME>
アプリケーションからログを収集するには、Agent の構成ディレクトリのルートに以下の内容の <APP_NAME>.d/conf.yaml
ファイルを作成します。
logs:
- type: tcp
port: 10518
service: "<APP_NAME>"
source: "<CUSTOM_SOURCE>"
Serilog を使用している場合、UDP を使用して接続するには、Serilog.Sinks.Network
オプションを使用します。
Agent バージョン 7.31.0 以降では、TCP 接続はアイドル状態でも無期限に開いたままになります。
注: Agent は、単純文字列、JSON、および Syslog 形式のログをサポートします。複数のログを一度に送信する場合は、改行文字を使用してログを区切ってください。
journald からログを収集するには、Agent の構成ディレクトリのルートに以下の内容の journald.d/conf.yaml
ファイルを作成します。
logs:
- type: journald
path: /var/log/journal/
コンテナ化環境およびユニットフィルタリングの設定については、journald インテグレーションに関するドキュメントを参照してください。
Windows のイベントをログとして Datadog に送信するには、conf.d/win32_event_log.d/conf.yaml
にチャンネルを手動で追加するか、Datadog Agent Manager を使用します。
チャンネルリストを表示するには、PowerShell で以下のコマンドを実行します。
Get-WinEvent -ListLog *
最もアクティブなチャンネルを表示するには、PowerShell で以下のコマンドを実行します。
Get-WinEvent -ListLog * | sort RecordCount -Descending
次に、チャンネルを win32_event_log.d/conf.yaml
構成ファイルに追加します。
logs:
- type: windows_event
channel_path: "<CHANNEL_1>"
source: "<CHANNEL_1>"
service: "<SERVICE>"
sourcecategory: windowsevent
- type: windows_event
channel_path: "<CHANNEL_2>"
source: "<CHANNEL_2>"
service: "<SERVICE>"
sourcecategory: windowsevent
<CHANNEL_X>
パラメーターは、イベントの収集に使用する Windows チャンネル名に変更してください。
インテグレーションの自動処理パイプライン設定を利用するには、対応する source
パラメーターを同じチャンネル名に設定します。
最後に、Agent を再起動します。
ログの収集に使用可能なパラメーターのリスト
パラメーター | 必須 | 説明 |
---|---|---|
type | 〇 | ログ入力ソースの種類。有効な値は、tcp 、udp 、file 、windows_event 、docker 、journald です。 |
port | 〇 | type が tcp または udp の場合、ログをリスニングするポートを設定します。 |
path | 〇 | type が file または journald の場合、ログを収集するファイルパスを設定します。 |
channel_path | 〇 | type が windows_event の場合、ログを収集する Windows イベントチャンネルをリストします。 |
service | 〇 | ログを所有しているサービスの名前。ご使用のサービスを Datadog APM でインスツルメントしている場合、これは同じサービス名にする必要があります。複数のデータタイプにわたって service を構成する場合は、統合サービスタグ付けの手順を確認してください。 |
source | 〇 | ログを送信しているインテグレーションを定義する属性。既存のインテグレーションに由来するログでない場合、このフィールドはカスタムソース名にすることができます。ただし、関連して収集しているカスタムメトリクスがある場合は、そのネームスペースと一致させることをお勧めします。たとえば、myapp.request.count の myapp を使用します。 |
include_units | ✕ | type が journald の場合、対象とする journald ユニットのリスト。 |
exclude_paths | ✕ | type が file で、path にワイルドカード文字が含まれている場合、ログ収集から除外する必要がある一致するファイルをリストします。6.18 以降の Agent バージョンで使用できます。 |
exclude_units | ✕ | type が journald の場合、対象としない journald ユニットのリスト。 |
sourcecategory | ✕ | ソース属性が属するカテゴリーの定義に使用される属性。たとえば、source:postgres、sourcecategory:database、 source: apache, sourcecategory: http_web_access` です。 |
start_position | ✕ | type が file の場合、Agent がファイルの読み込みを開始する位置を設定します。有効な値は beginning と end (デフォルトは end ) です。path にワイルドカード文字が含まれている場合、beginning はサポートされません。Agent v6.19/v7.19 で追加されましたtype が journald の場合、Agent がジャーナルの読み込みを開始する位置を設定します。有効な値は beginning 、end 、forceBeginning 、forceEnd です (デフォルトは end )。force オプションを指定すると、Agent はディスクに保存されているカーソルを無視し、開始時に常にジャーナルの先頭または末尾から読み込みます。Agent v7.38 で追加されました |
encoding | ✕ | type が file の場合、Agent がファイルを読み込む際のエンコーディングを設定します。UTF-16 リトルエンディアン の場合は utf-16-le に、UTF-16 ビッグエンディアンの場合は utf-16-be に、Shift JIS の場合は shift-jis に設定します。その他の値に設定すると、Agent はファイルを UTF-8 形式で読み込みます。utf-16-le および utf-16be は Agent v6.23/v7.23 の、shift-jis は Agent v6.34/v7.34 の追加機能です |
tags | ✕ | 収集される各ログに追加するタグのリスト (タグ付けの詳細はこちら)。 |