WinNetFlow
WinNetFlow は Windows Event Tracing(ETW)で Microsoft-Windows-TCPIP Provider の TCP/UDP イベントを監視し、プロセス別のレイヤー 4 トラフィック(バイト、パケット、再送、RTT、TCP 状態)を集計します。主要フィールドと端点の役割は Linux の ebpf-net/netflow と互換で、src/dst、client/server、conn_side、トラフィックフィールドを使うホストネットワーク画面を再利用できます。
Microsoft-Windows-HttpService Provider から HTTP 要求メトリクス(httpflow、既定で有効)も収集します。IIS、HttpListener、ASP.NET Core など HTTP.sys ベースのサービスを対象とし、Linux の ebpf-net/httpflow とフィールド互換です。
設定¶
前提条件¶
- OS:Windows 10 / Windows Server 2016 以降(64 ビット)
- 管理者権限で実行してください(リアルタイム ETW セッション作成に必要)
- eBPF コレクターとは独立して有効にできます。同一ホストではどちらか一方のみ有効になります
DataKit のインストール先の conf.d/samples で、winnetflow.conf.sample をコピーして winnetflow.conf とします。例:
[[inputs.winnetflow]]
# Flow aggregation and report interval.
interval = "60s"
# Optional ETW session tuning. Buffer size is in KB; unsafe values are
# clamped to documented limits and a 256 MiB per-session memory budget.
# etw_buffer_size_kb = 64
# etw_min_buffers = 8
# etw_max_buffers = 256
# Max flows tracked per interval; excess new flows are dropped and counted.
# max_flows = 65536
# Collect L7 HTTP request metrics from the HTTP.sys ETW provider (IIS,
# HttpListener and other HTTP.sys clients) as the "httpflow" measurement.
# enable_httpflow = true
# Max in-flight HTTP requests tracked; excess new requests are dropped and
# counted in the periodic summary.
# max_http_requests = 65536
# Max request path length collected; longer paths are truncated and flagged.
# httpflow_path_limit = 256
[inputs.winnetflow.tags]
# some_tag = "some_value"
設定後、DataKit を再起動します。
ConfigMap による設定注入または ENV_DATAKIT_INPUTS の設定で有効にできます。
環境変数でも設定を変更できます(ENV_DEFAULT_ENABLED_INPUTS に既定コレクターとして追加が必要):
-
ENV_INPUT_WINNETFLOW_INTERVAL
コレクターの実行間隔
フィールド型: Duration
コレクター設定フィールド:
interval既定値: 10s
-
ENV_INPUT_WINNETFLOW_ETW_BUFFER_SIZE_K_B
ETW セッションのバッファサイズ(KB、4~1024)。
フィールド型: Int
コレクター設定フィールド:
etw_buffer_size_k_b例: 64
-
ENV_INPUT_WINNETFLOW_ETW_MIN_BUFFERS
ETW セッションの最小バッファ数(2~4096)。
フィールド型: Int
コレクター設定フィールド:
etw_min_buffers例: 8
-
ENV_INPUT_WINNETFLOW_ETW_MAX_BUFFERS
ETW セッションの最大バッファ数。セッションごとの 256 MiB メモリ予算にも制限されます。
フィールド型: Int
コレクター設定フィールド:
etw_max_buffers例: 256
-
ENV_INPUT_WINNETFLOW_MAX_FLOWS
周期ごとの最大同時フロー数。超過分は破棄して計数します。
フィールド型: Int
コレクター設定フィールド:
max_flows例: 65536
-
ENV_INPUT_WINNETFLOW_ENABLE_HTTP_FLOW
HTTP.sys ETW Provider の L7 httpflow 収集を有効にするか。
フィールド型: Boolean
コレクター設定フィールド:
enable_http_flow例: true
-
ENV_INPUT_WINNETFLOW_MAX_HTTP_REQUESTS
追跡する最大同時 HTTP 要求数。超過分は破棄して計数します。
フィールド型: Int
コレクター設定フィールド:
max_http_requests例: 65536
-
ENV_INPUT_WINNETFLOW_HTTP_FLOW_PATH_LIMIT
収集する要求パスの最大長。超過分は切り詰めてフラグを設定します。
フィールド型: Int
コレクター設定フィールド:
http_flow_path_limit例: 256
-
ENV_INPUT_WINNETFLOW_TAGS
カスタム tag。設定ファイルの同名 tag を上書きします。
フィールド型: String
コレクター設定フィールド:
tags例:
'tag1=value1,tag2=value2'
メトリクス¶
以下のデータにはグローバル tag host(DataKit ホスト名)を既定で付加します。[inputs.winnetflow.tags] で他の tag も指定できます:
| Tags & Fields | Description |
|---|---|
| client_ip ( tag) |
Client endpoint IP address. |
| client_ip_type ( tag) |
Client IP type: private, loopback, multicast or other. |
| client_port ( tag) |
Client endpoint port. |
| conn_side ( tag) |
Local connection role: client or server. |
| direction ( tag) |
Flow direction: incoming or outgoing. |
| dst_ip ( tag) |
Destination IP address. |
| dst_ip_type ( tag) |
Destination IP type: private, loopback, multicast or other. |
| dst_nat_ip ( tag) |
Destination NAT IP; N/A because Windows ETW does not expose NAT translation. |
| dst_nat_port ( tag) |
Destination NAT port; N/A because Windows ETW does not expose NAT translation. |
| dst_port ( tag) |
Destination port. |
| family ( tag) |
IP family: IPv4 or IPv6. |
| pid ( tag) |
Process ID owning the connection. |
| process_name ( tag) |
Process name owning the connection. |
| server_ip ( tag) |
Server endpoint IP address. |
| server_ip_type ( tag) |
Server IP type: private, loopback, multicast or other. |
| server_port ( tag) |
Server endpoint port. |
| src_ip ( tag) |
Source IP address. |
| src_ip_type ( tag) |
Source IP type: private, loopback, multicast or other. |
| src_port ( tag) |
Source port. |
| transport ( tag) |
Transport protocol: tcp or udp. |
| bytes_read | Bytes read on this flow during the interval. Type: int | (gauge) Unit: digital,B |
| bytes_written | Bytes written on this flow during the interval. Type: int | (gauge) Unit: digital,B |
| client_sent | Bytes sent by the client during the interval. Type: int | (gauge) Unit: digital,B |
| packets_read | Packets read on this flow during the interval (approximate on Windows). Type: int | (gauge) Unit: count |
| packets_written | Packets/messages written during the interval; always 0 for TCP because TCPIP send events do not expose a packet count, and approximated by message count for UDP. Type: int | (gauge) Unit: count |
| retransmits | TCP retransmissions on this flow during the interval. Type: int | (gauge) Unit: count |
| rtt | Average smoothed TCP RTT in microseconds. Type: int | (gauge) Unit: time,μs |
| rtt_var | Average TCP RTT variance in microseconds. Type: int | (gauge) Unit: time,μs |
| server_sent | Bytes sent by the server during the interval. Type: int | (gauge) Unit: digital,B |
| tcp_close_wait | TCP transitions into CLOSE_WAIT state during the interval. Type: int | (gauge) Unit: count |
| tcp_closed | TCP connections closed during the interval. Type: int | (gauge) Unit: count |
| tcp_connect_attempts | TCP active connect attempts during the interval. Type: int | (gauge) Unit: count |
| tcp_connect_failures | TCP active connect failures during the interval. Type: int | (gauge) Unit: count |
| tcp_established | TCP connections established during the interval. Type: int | (gauge) Unit: count |
| tcp_last_ack | TCP transitions into LAST_ACK state during the interval. Type: int | (gauge) Unit: count |
| tcp_time_wait | TCP transitions into TIME_WAIT state during the interval. Type: int | (gauge) Unit: count |
| Tags & Fields | Description |
|---|---|
| client_ip ( tag) |
Client endpoint IP address. |
| client_ip_type ( tag) |
Client IP type: private, loopback, multicast or other. |
| client_port ( tag) |
Client endpoint port. |
| conn_side ( tag) |
Local connection role, always server for HTTP.sys. |
| direction ( tag) |
Flow direction, always incoming for the HTTP.sys server side. |
| dst_ip ( tag) |
Client IP address (remote endpoint). |
| dst_ip_type ( tag) |
Client destination IP type: private, loopback, multicast or other. |
| dst_nat_ip ( tag) |
Destination NAT IP; N/A because Windows ETW does not expose NAT translation. |
| dst_nat_port ( tag) |
Destination NAT port; N/A because Windows ETW does not expose NAT translation. |
| dst_port ( tag) |
Client port. |
| family ( tag) |
IP family: IPv4 or IPv6. |
| pid ( tag) |
Server process ID reported by HTTP.sys on the response event. |
| process_name ( tag) |
Server process name resolved from the HTTP.sys response event PID (for example, w3wp.exe). |
| server_ip ( tag) |
Server endpoint IP address. |
| server_ip_type ( tag) |
Server IP type: private, loopback, multicast or other. |
| server_port ( tag) |
Server endpoint port. |
| src_ip ( tag) |
Server IP address (local endpoint). |
| src_ip_type ( tag) |
Server source IP type: private, loopback, multicast or other. |
| src_port ( tag) |
Server port. |
| transport ( tag) |
Transport protocol, always tcp. |
| bytes_read | Bytes read on this flow during the interval (always 0; HTTP.sys does not expose request body sizes). Type: int | (gauge) Unit: digital,B |
| bytes_written | Bytes written on this flow during the interval (populated for cache-served responses). Type: int | (gauge) Unit: digital,B |
| client_sent | Bytes sent by the HTTP client; always 0 because HTTP.sys does not expose request body sizes. Type: int | (gauge) Unit: digital,B |
| count | Number of HTTP requests in this group during the interval. Type: int | (gauge) Unit: count |
| http_version | HTTP version; empty because HTTP.sys events do not carry it. Type: string | (string) Unit: N/A |
| latency | Average request processing time (receive to send complete) in nanoseconds. Type: int | (gauge) Unit: time,ns |
| method | HTTP method (GET/POST/...). Type: string | (string) Unit: N/A |
| path | Request path. Type: string | (string) Unit: N/A |
| server_sent | Bytes sent by the HTTP server during the interval. Type: int | (gauge) Unit: digital,B |
| status_code | HTTP response status code. Type: int | (gauge) Unit: N/A |
| truncated | Request path reached the configured length limit and was truncated. Type: bool | (gauge) Unit: bool |
既知の制限¶
- TCP 送信イベントにパケット数がないため、TCP の
packets_writtenは常に 0 です。UDP はメッセージ数で近似します。 - UDP には接続の概念がありません。非一時ポートにバインドしたソケットから推定し、待受ポートに一致すれば
incoming、それ以外はoutgoingとします。 - 収集開始前の TCP 接続はローカル待受ポートのスナップショットで判定し、一致なら
incoming、それ以外はoutgoingとします。スナップショットは 30 秒ごとに更新します。 - Windows ETW はネットワーク名前空間、Kubernetes 端点情報、DNS、NAT 情報を提供しません。
dst_nat_ipとdst_nat_portはN/A固定です。必要な Kubernetes/名前空間 tag は別途グローバル tag で補足してください。 - 高トラフィックでは ETW イベントが失われる場合があります。10 分ごとにセッション統計(デコード、破棄、解析エラー、セッション損失)を出力し、異常時は警告ログを記録します。
- 周期ごとのフロー数は制限されます(既定 65536、
max_flows)。接続急増時の超過フローは破棄し、flows_skippedに計上します。 httpflowは HTTP.sys 経由の HTTP のみ対象です(IIS/HttpListener/ASP.NET Core など)。一部の Go/Node など独自ソケットのサービスは収集しません。- HTTP.sys イベントには HTTP バージョンと要求本文サイズがありません。
http_versionは空、bytes_readは 0 固定で、bytes_writtenはキャッシュ応答(event 16)のみ取得できます。 - HTTP プロセスの特定はベストエフォートです。接続イベントの PID はクライアントのため無視し、HTTP.sys 応答時にサーバー PID を解決します。名前取得前に終了した場合、
process_nameがunknownになることがあります。 - 同時 HTTP 要求数には上限があります(既定 65536、
max_http_requests)。超過分は破棄し周期ログに計上します。機密情報の漏えいと無制限のカーディナリティを防ぐため URL クエリは収集しません。パスがhttpflow_path_limit(既定 256)を超えると切り詰め、truncatedを設定します。