eCDN Logpush Filter

Create eCDN Logpush Job with Filter 

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}`

Successful Response 

A successful response returns 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}

Filter Detail 

The following table shows the supported comparison operators along with example values.

To add filters, provide the filter criteria in the form of escaped JSON strings with the format {\"where\":{\"key"\:\"<field>\",\"operator\":\"<comparison_operator>\",\"value\":\"<value>\"}}.

  • The \“Key”\ field value must correspond to one of the available fields listed in eCDN Logpush Log Field.
  • For the Firewall events dataset, filtering is not supported for the following fields: Action, Description, Kind, MatchIndex,Metadata, OriginatorRayID, RuleID, and Source.

Note

NameOperator NotationSupported Field TypesExample
EqualeqString, Int, Bool{\“where\":{\"key\":\"ClientRequestHost\",\"operator\":\"eq\",\"value\":\"example.com\"}}
Not equal!eqString, Int, Bool{\“where\":{\"key\":\"ClientCountry\",\"operator\":\"!eq\",\"value\":\"ca\"}}
Less thanltInt{\“where\":{\"key\":\"BotScore\",\"operator\":\"lt\",\"value\":\"30\"}}
Less than or equalleqInt{\“where\":{\"key\":\"BotScore\",\"operator\":\"leq\",\"value\":\"30\"}}
Greater thangtInt{\“where\":{\"key\":\"BotScore\",\"operator\":\"gt\",\"value\":\"30\"}}
Greater than or equalgeqInt{\“where\":{\"key\":\"BotScore\",\"operator\":\"geq\",\"value\":\"30\"}}
Starts withstartsWithString{\“where\":{\"key\":\"ClientRequestPath\",\"operator\":\"startsWith\",\"value\":\"/foo\"}}
Ends withendsWithString{\“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\"}}
ContainscontainsString, 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 valuesinString, 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]}}

Logical Operators in Filter 

  • Filters can be connected using AND, OR logical operators.
  • Logical operators can be nested.

Here are some examples of how the logical operators can be implemented. X, Y, and Z are used to represent filter criteria:

  • 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 Request 

In this example, the eCDN logpush job sends the logs to the S3 bucket only if the log has ClientRequestPath that contains “/example-path” and EdgeResponseStatus includes 502, 503, and 504.

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}`