Skip to content

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

Log Explorer API

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

設定とログ検索は、公開 API からも利用できます。

認証

API の認証は、API トークン、または API キーとメールアドレスで行えます。手順は API トークンの作成 を参照してください。

Log Explorer の各機能に必要な権限の詳細は、権限 セクションを参照してください。

データを照会する

Log Explorer には、クエリ送信用の SQL API があります。

たとえば、特定の Ray ID を持つ HTTP リクエストを探すには、次の SQL クエリを使います。

curl https://api.cloudflare.com/client/v4/zones/{zone_id}/logs/explorer/query/sql \
--header "Authorization: Bearer <API_TOKEN>" \
--url-query query="SELECT clientRequestScheme, clientRequestHost, clientRequestMethod, edgeResponseStatus, clientRequestUserAgent FROM http_requests WHERE RayID = '806c30a3cec56817' LIMIT 1"

このコマンドは、次の HTTP リクエスト詳細を返します。

{
	"result": [
		{
			"clientrequestscheme": "https",
			"clientrequesthost": "example.com",
			"clientrequestmethod": "GET",
			"clientrequestuseragent": "curl/7.88.1",
			"edgeresponsestatus": 200
		}
	],
	"success": true,
	"errors": [],
	"messages": []
}

別の例として、特定の時間範囲から選択した列の Cloudflare Access リクエストを探す SQL クエリは次のとおりです。

curl https://api.cloudflare.com/client/v4/accounts/{account_id}/logs/explorer/query/sql \
--header "Authorization: Bearer <API_TOKEN>" \
--url-query query="SELECT CreatedAt, AppDomain, AppUUID, Action, Allowed, Country, RayID, Email, IPAddress, UserUID FROM access_requests WHERE Date >= '2025-02-06' AND Date <= '2025-02-06' AND CreatedAt >= '2025-02-06T12:28:39Z' AND CreatedAt <= '2025-02-06T12:58:39Z'"

このコマンドは、次のリクエスト詳細を返します。

{
	"result": [
		{
			"createdat": "2025-01-14T18:17:55Z",
			"appdomain": "example.com",
			"appuuid": "a66b4ab0-ccdf-4d60-a6d0-54a59a827d92",
			"action": "login",
			"allowed": true,
			"country": "us",
			"rayid": "90fbb07c0b316957",
			"email": "[email protected]",
			"ipaddress": "1.2.3.4",
			"useruid": "52859e81-711e-4de0-8b31-283336060e79"
		}
	],
	"success": true,
	"errors": [],
	"messages": []
}

役に立ちましたか?