You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/logs/reference/custom-fields.mdx
+33-11Lines changed: 33 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,23 @@ sidebar:
6
6
7
7
---
8
8
9
-
You can configure custom fields — selected from the list of HTTP request headers, HTTP response headers, and cookies — to include in Logpush log entries of a zone. Custom fields are only available for the [HTTP requests dataset](/logs/reference/log-fields/zone/http_requests/). Once configured, these custom fields will be enabled for all the Logpush jobs in the zone that use the HTTP requests dataset and include the request headers, response headers, or cookie fields.
9
+
The HTTP requests dataset includes most standard log information by default. However, if you need to capture additional request or response headers or cookies, you can use custom fields to tailor the logs to your specific needs
10
+
11
+
Custom fields are configured per zone and, once set up, are enabled for all Logpush jobs in that zone that use the HTTP requests dataset and include the request headers, response headers, or cookie fields. You can log these fields in their raw form or as transformed values.
12
+
13
+
:::note[By default:]
14
+
-**Request headers** are logged as **raw values**.
15
+
-**Response headers** are logged as **transformed values**.
16
+
:::
17
+
18
+
This default behavior can be changed. You can configure either request or response headers to be logged as raw or transformed, depending on your needs - but not both for the same header.
10
19
11
20
Custom fields can be enabled via API or the Cloudflare dashboard.
12
21
22
+
:::note
23
+
Custom fields are only available for the [HTTP requests dataset](/logs/reference/log-fields/zone/http_requests/).
24
+
:::
25
+
13
26
## Enable custom rules via API
14
27
15
28
Use the [Rulesets API](/ruleset-engine/rulesets-api/) to create a rule that configures custom fields. For more information on concepts like phases, rulesets, and rules, as well as the available API operations, refer to the [Ruleset Engine](/ruleset-engine/) documentation.
@@ -27,20 +40,22 @@ The `action_parameters` object that you must include in the rule that configures
27
40
28
41
```json
29
42
"action_parameters": {
43
+
//select raw (default) or transformed request header
@@ -51,6 +66,7 @@ Ensure that your rule definition complies with the following:
51
66
* You must enter HTTP request and response header names in lower case.
52
67
* Cookie names are case sensitive — you must enter cookie names with the same capitalization they have in the HTTP request.
53
68
* You must set the rule expression to `true`.
69
+
* You can only log raw or transformed values for either request or response headers but not both for the same header.
54
70
55
71
Perform the following steps to create the rule:
56
72
@@ -101,11 +117,14 @@ Perform the following steps to create the rule:
101
117
"request_fields": [
102
118
{ "name": "content-type" },
103
119
{ "name": "x-forwarded-for" },
104
-
{ "name": "host" }
105
120
],
121
+
"transformed_request_fields": [
122
+
{"name": "host"}
123
+
],
106
124
"response_fields": [
107
125
{ "name": "server" },
108
126
{ "name": "content-type" },
127
+
"raw_response_fields": [
109
128
{ "name": "allow" }
110
129
],
111
130
"cookie_fields": [
@@ -138,11 +157,13 @@ Perform the following steps to create the rule:
138
157
"request_fields": [
139
158
{ "name": "content-type" },
140
159
{ "name": "x-forwarded-for" },
160
+
"transformed_request_fields": [
141
161
{ "name": "host" }
142
162
],
143
163
"response_fields": [
144
164
{ "name": "server" },
145
165
{ "name": "content-type" },
166
+
"raw_response_fields": [
146
167
{ "name": "allow" }
147
168
],
148
169
"cookie_fields": [
@@ -212,3 +233,4 @@ If you are a Cloudflare Access user, as of March 2022 you have to manually add t
212
233
* For headers which may be included multiple times (for example, the `set-cookie` response header), a custom field will only log the first instance of the header. Subsequent headers of the same type will be ignored.
213
234
* Currently, Cloudflare only logs original request/response headers. Headers that were modified earlier in the request lifecycle with [Transform Rules](/rules/transform/) will not be logged.
214
235
* The request header `Range` is currently not supported by Custom Fields.
236
+
* Transformed and raw values for request and response headers are available only via the API and cannot be set through the UI.
0 commit comments