eCDN Logpush フィルター

フィルターを使用した eCDN Logpush ジョブの作成 

1curl "https://{shortcode}.api.commercecloud.salesforce.com/cdn/zones/v1/organizations/f_ecom_bcxj_prd/zones/{zoneId}/logpush/jobs"
2--request 'POST' \
3--header 'Authorization: Bearer <access_token>' \
4--header 'Content-Type: application/json' \
5--data-raw `{
6  "name": "ExampleLogPushJob",
7  "destinationPath": "s3://example-bucket/log?region=us-east-1",
8  "logType": "http_requests",
9  "ownershipChallengeToken": "Put your ownership challenge token here",
10  "filter": "{\"where\":{\"key\":\"ClientRequestPath\",\"operator\":\"contains\",\"value\":\"/example-path\"}}"
11  "logFields": [
12    "CacheCacheStatus",
13    "CacheResponseBytes",
14    "ClientRequestPath",
15    "ClientRequestBytes",
16    "ClientRequestHost",
17    "ClientRequestUserAgent",
18    "EdgeResponseStatus",
19    "EdgeResponseBytes",
20    "EdgeStartTimestamp",
21    "EdgeTimeToFirstByteMs"
22  ]
23}`

成功レスポンス 

成功した場合は、201 が返されます。

1{
2  "data": {
3    "jobId": 213543,
4    "name": "ExampleLogPushJob",
5    "logType": "http_requests",
6    "logFields": [
7      "CacheCacheStatus",
8      "CacheResponseBytes",
9      "ClientRequestPath",
10      "ClientRequestBytes",
11      "ClientRequestHost",
12      "ClientRequestUserAgent",
13      "EdgeResponseStatus",
14      "EdgeResponseBytes",
15      "EdgeStartTimestamp",
16      "EdgeTimeToFirstByteMs"
17    ],
18    "filter": "{\"where\":{\"key\":\"ClientRequestPath\",\"operator\":\"contains\",\"value\":\"/example-path\"}}",
19    "destinationPath": "s3://example-bucket/log?region=us-east-1",
20    "enabled": false,
21    "createdOn": "2023-04-18T17:18:43Z"
22  }
23}

フィルターの詳細 

次の表に、サポートされている比較演算子と、値の例を示します。

フィルターを追加するには、次の形式のエスケープされた JSON 文字列の形式でフィルター条件を指定します: {\"where\":{\"key"\:\"<field>\",\"operator\":\"<comparison_operator>\",\"value\":\"<value>\"}}

\“Key”\ フィールド値は、eCDN Logpush ログフィールド にリストされている利用可能なフィールドの 1 つに対応する必要があります。

Note

名前演算子の表記法サポートされているフィールドタイプ
Equal (等しい)eqString, Int, Bool{\“where\":{\"key\":\"ClientRequestHost\",\"operator\":\"eq\",\"value\":\"example.com\"}}
Not equal (等しくない)!eqString, Int, Bool{\“where\":{\"key\":\"ClientCountry\",\"operator\":\"!eq\",\"value\":\"ca\"}}
Less than (より小さい)ltInt{\“where\":{\"key\":\"BotScore\",\"operator\":\"lt\",\"value\":\"30\"}}
Less than or equal (以下)leqInt{\“where\":{\"key\":\"BotScore\",\"operator\":\"leq\",\"value\":\"30\"}}
Greater than (より大きい)gtInt{\“where\":{\"key\":\"BotScore\",\"operator\":\"gt\",\"value\":\"30\"}}
Greater than or equal (以上)geqInt{\“where\":{\"key\":\"BotScore\",\"operator\":\"geq\",\"value\":\"30\"}}
Starts with (次の値で始まる)startsWithString{\“where\":{\"key\":\"ClientRequestPath\",\"operator\":\"startsWith\",\"value\":\"/foo\"}}
Ends with (次の値で終わる)endsWithString{\“where\":{\"key\":\"ClientRequestPath\",\"operator\":\"endsWith\",\"value\":\"/foo\"}}
Does not start with (次の値で始まらない)startsWithString{\“where\":{\"key\":\"ClientRequestPath\",\"operator\":\"!startsWith\",\"value\":\"/foo\"}}
Does not end with (次の値で終わらない)!endsWithString{\“where\":{\"key\":\"ClientRequestPath\",\"operator\":\"!endsWith\",\"value\":\"/foo\"}}
Contains (含む)containsString, Bool{\“where\":{\"key\":\"ClientRequestPath\",\"operator\":\"contains\",\"value\":\"/static\"}}
Does not contain (含まない)containsString, Bool{\“where\":{\"key\":\"ClientRequestPath\",\"operator\":\"!contains\",\"value\":\"/static\"}}
Value is in a set of values (値は値のセット内にあり)inString, Int, Array{\“where\":{\"key\":\"EdgeResponseStatus\",\"operator\":\"in\",\"value\":[200,201]}}
Value is not in a set of values (値は値のセット内になし)inString, Int, Array{\“where\":{\"key\":\"EdgeResponseStatus\",\"operator\":\"!in\",\"value\":[200,201]}}

フィルター内の論理演算子 

  • フィルターは、AND, OR 論理演算子を使用して接続できます。
  • 論理演算子はネストできます。

ここで、論理演算子を実装する方法の例をいくつか示します。X、Y、Z はフィルター条件を表すために使用されます。

  • X AND Y AND Z - {"where":{"and":[{X},{Y},{Z}]}}
  • X OR Y OR Z - {"where":{"or":[{X},{Y},{Z}]}}
  • X AND (Y OR Z) - {"where":{"and":[{X}, {"or":[{Y},{Z}]}]}}
  • (X AND Y) OR Z - {"where":{"or":[{"and": [{X},{Y}]},{Z}]}}

リクエストの例 

この例では、ログに “/example-path” が含まれる ClientRequestPath があり、かつ EdgeResponseStatus に 502、503、および 504 が含まれる場合のみ、eCDN logpush ジョブはログを S3 バケットに送信します。

1curl "https://{shortcode}.api.commercecloud.salesforce.com/cdn/zones/v1/organizations/f_ecom_bcxj_prd/zones/{zoneId}/logpush/jobs`
2--request 'POST' \
3--header 'Authorization: Bearer <access_token>' \
4--header 'Content-Type: application/json' \
5--data-raw `{
6  "name": "ExampleLogPushJob",
7  "destinationPath": "s3://example-bucket/log?region=us-east-1",
8  "logType": "http_requests",
9  "ownershipChallengeToken": "Put your ownership challenge token here",
10  "filter": "{\"where\":{\"and\":[{\"key\":\"ClientRequestPath\",\"operator\":\"contains\",\"value\":\"/example-path\"}, {\"key\":\"EdgeResponseStatus\",\"operator\":\"in\",\"value\":[502, 503, 504]}]}}",
11  "logFields": [
12    "CacheCacheStatus",
13    "CacheResponseBytes",
14    "ClientRequestPath",
15    "ClientRequestBytes",
16    "ClientRequestHost",
17    "ClientRequestUserAgent",
18    "EdgeResponseStatus",
19    "EdgeResponseBytes",
20    "EdgeStartTimestamp",
21    "EdgeTimeToFirstByteMs"
22  ]
23}`