Skip to content

非公式本サイトは非公式の日本語ドキュメントであり、Cloudflare 公式サイトではありません。最新情報はdevelopers.cloudflare.comをご確認ください。

Network Firewall ログフィルター

最終更新 Markdown で表示Agent セットアップ

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)。無効なルールでは、ルールがパケットを評価してもアクションを強制しないため、VerdictOutcome が異なることがあります。

有効なルールまたは無効なルールで絞り込む

次のフィルター例で、Cloudflare Network Firewall のトラフィックを、有効なルールまたは無効なルールのイベントに絞り込めます。

次の例は、Cloudflare Network Firewall に関連するフィールドだけを表示する Logpush ジョブを作成 し、フィルターは無効なルールのイベントだけを表示します。

Required API token permissions

At least one of the following token permissions is required:
  • Logs Write
Create Logpush jobbash
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
Create Logpush jobbash
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
Create Logpush jobbash
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
Create Logpush jobbash
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\":\"\"}]}}"
	}'

Network Firewall イベントだけに絞り込む

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
Create Logpush jobbash
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\"}}"
	}'

役に立ちましたか?