Logpush ジョブに ログフィルター を適用すると、特定の Cloudflare Network Firewall イベントだけをエクスポートできます。次の例は、Logpush API を使ったよくあるフィルター設定です。各フィルターは JSON 構造で、where 句に key(フィルター対象のログフィールド)、operator(比較。eq は等しい、!eq は等しくない)、value(照合する値)を含めます。
このガイドのフィルターは、次のログフィールドを使います。
MitigationSystem— パケットをサンプリングした Cloudflare システムを識別します。Network Firewall イベントでは、この値はmagic-firewallです。RulesetID— パケットに一致したルールを含むマネージドルールセットの一意の識別子です。一致がない場合は空文字です。Outcome— Cloudflare システムがパケットに対して実行したアクションです(passまたはdrop)。Verdict— Cloudflare システムがパケットに対して実行すべきと判断したアクションです(passまたはdrop)。無効なルールでは、ルールがパケットを評価してもアクションを強制しないため、VerdictとOutcomeが異なることがあります。
次のフィルター例で、Cloudflare Network Firewall のトラフィックを、有効なルールまたは無効なルールのイベントに絞り込めます。
次の例は、Cloudflare Network Firewall に関連するフィールドだけを表示する Logpush ジョブを作成 し、フィルターは無効なルールのイベントだけを表示します。
Required API token permissions
At least one of the following token permissions is required:Logs Write
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/logpush/jobs" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"destination_conf": "<DESTINATION_CONF>",
"output_options": {
"field_names": [
"ColoName",
"Datetime",
"Direction",
"IPDestinationAddress",
"IPDestinationSubnet",
"IPProtocol",
"IPSourceAddress",
"IPSourceSubnet",
"Outcome",
"RuleID",
"RulesetID",
"SampleInterval",
"Verdict"
]
},
"filter": "{\"where\":{\"or\":[{\"and\":[{\"key\":\"MitigationSystem\",\"operator\":\"eq\",\"value\":\"magic-firewall\"},{\"key\":\"RulesetID\",\"operator\":\"!eq\",\"value\":\"\"},{\"key\":\"Outcome\",\"operator\":\"eq\",\"value\":\"pass\"},{\"key\":\"Verdict\",\"operator\":\"eq\",\"value\":\"drop\"}]}]}}"
}'次の例は、Cloudflare Network Firewall に関連するフィールドだけを表示する Logpush ジョブを作成 し、フィルターは有効なルールのイベントだけを表示します。
Required API token permissions
At least one of the following token permissions is required:Logs Write
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/logpush/jobs" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"destination_conf": "<DESTINATION_CONF>",
"output_options": {
"field_names": [
"ColoName",
"Datetime",
"Direction",
"IPDestinationAddress",
"IPDestinationSubnet",
"IPProtocol",
"IPSourceAddress",
"IPSourceSubnet",
"Outcome",
"RuleID",
"RulesetID",
"SampleInterval",
"Verdict"
]
},
"filter": "{\"where\":{\"or\":[{\"and\":[{\"key\":\"MitigationSystem\",\"operator\":\"eq\",\"value\":\"magic-firewall\"},{\"key\":\"RulesetID\",\"operator\":\"!eq\",\"value\":\"\"},{\"or\":[{\"key\":\"Outcome\",\"operator\":\"eq\",\"value\":\"drop\"},{\"key\":\"Verdict\",\"operator\":\"eq\",\"value\":\"pass\"}]}]}]}}"
}'次のフィルター例で、Cloudflare Network Firewall のトラフィックを、許可またはブロックされたイベントに絞り込めます。
次の例は、Cloudflare Network Firewall に関連するフィールドだけを表示する Logpush ジョブを作成 し、フィルターは明示的なアクションがなかったイベントだけを表示します。つまり、どのルールにも一致せずファイアウォールを通過したパケットです。デフォルトでは、Cloudflare Network Firewall は一致しないトラフィックを許可します。これは空の RulesetID で識別します。
Required API token permissions
At least one of the following token permissions is required:Logs Write
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/logpush/jobs" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"destination_conf": "<DESTINATION_CONF>",
"output_options": {
"field_names": [
"ColoName",
"Datetime",
"Direction",
"IPDestinationAddress",
"IPDestinationSubnet",
"IPProtocol",
"IPSourceAddress",
"IPSourceSubnet",
"Outcome",
"RuleID",
"RulesetID",
"SampleInterval",
"Verdict"
]
},
"filter": "{\"where\":{\"and\":[{\"key\":\"MitigationSystem\",\"operator\":\"eq\",\"value\":\"magic-firewall\"},{\"key\":\"RulesetID\",\"operator\":\"eq\",\"value\":\"\"}]}}"
}'次の例は、Cloudflare Network Firewall に関連するフィールドだけを表示する Logpush ジョブを作成 し、フィルターは明示的なアクションがあったイベントだけを表示します。この例には、有効な Cloudflare Network Firewall ルールと無効なルールの両方を含めます。
Required API token permissions
At least one of the following token permissions is required:Logs Write
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/logpush/jobs" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"destination_conf": "<DESTINATION_CONF>",
"output_options": {
"field_names": [
"ColoName",
"Datetime",
"Direction",
"IPDestinationAddress",
"IPDestinationSubnet",
"IPProtocol",
"IPSourceAddress",
"IPSourceSubnet",
"Outcome",
"RuleID",
"RulesetID",
"SampleInterval",
"Verdict"
]
},
"filter": "{\"where\":{\"and\":[{\"key\":\"MitigationSystem\",\"operator\":\"eq\",\"value\":\"magic-firewall\"},{\"key\":\"RulesetID\",\"operator\":\"!eq\",\"value\":\"\"}]}}"
}'Logpush ジョブに複数の Cloudflare 緩和システムのイベントが含まれる場合は、次のフィルターで Cloudflare Network Firewall イベントだけを含めます。次の例は、MitigationSystem で絞り込む Logpush ジョブを作成 し、Network Firewall トラフィックだけを含めます。
Required API token permissions
At least one of the following token permissions is required:Logs Write
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/logpush/jobs" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"destination_conf": "<DESTINATION_CONF>",
"output_options": {
"field_names": [
"ColoName",
"Datetime",
"Direction",
"IPDestinationAddress",
"IPDestinationSubnet",
"IPProtocol",
"IPSourceAddress",
"IPSourceSubnet",
"Outcome",
"RuleID",
"RulesetID",
"SampleInterval",
"Verdict"
]
},
"filter": "{\"where\":{\"key\":\"MitigationSystem\",\"operator\":\"eq\",\"value\":\"magic-firewall\"}}"
}'