Skip to content

Commit f93b5cc

Browse files
committed
ngx-http-log-json: 0.0.4 release
module: variable $http_log_json_req_headers; Creates a json object with all request headers. Example: ``` "req": { "headers": { "Host": "localhost", "User-Agent": "curl/7.52.1", "Accept": "*/*" } } ``` ---- module: variable $http_log_json_req_body; Log request body encoded as base64. It requires proxy_pass configuration at logging location. Example: ``` "req": { "body": "Zm9v" } ``` ---- module: location directive http_log_json_req_body_limit 512; Default limit is 512 bytes. Argument is a size string. May be 1k or 1M, but avoid this! ---- module: variable $http_log_json_resp_headers; Creates a json object with available response headers. Example: ``` resp": { "headers": { "Last-Modified": "Sat, 01 Apr 2017 13:34:28 GMT", "ETag": "\"58dfac64-12\"", "X-Foo": "bar", "Accept-Ranges": "bytes" } ``` ----
1 parent 5ca3f7f commit f93b5cc

17 files changed

+1269
-104
lines changed

CHANGES

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Changes with ngx-http-log-json 0.0.4 4 Apr 2017
2+
*) module variable $http_log_json_req_headers
3+
*) module variable $http_log_json_resp_headers
4+
*) module variable $http_log_json_req_body
5+
*) local directive http_log_json_req_body_limit
6+
17
Changes with ngx-http-log-json 0.0.3 31 Mar 2017
28

39
*) allow to write to multiple destination with differente formats

README.md

Lines changed: 68 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ For this, known or previously setted variables, can be used by using the '$' bef
5454

5555
Common HTTP nginx builtin variables like $uri, or any other variable set by other handler modules can be used.
5656

57+
Additional variables are provided by this module. See the available variables below at [Variables section](#variables).
58+
5759
The output is sent to the location specified by the first http_log_json_format argument.
5860
The possible output locations are:
5961

@@ -214,41 +216,94 @@ The format to use when writing to output destination.
214216

215217
---
216218

217-
* Syntax: **"http_log_json_kafka_compression** _compression_codec_;
219+
* Syntax: **http_log_json_kafka_compression** _compression_codec_;
218220
* Default: snappy
219221
* Context: http main
220222

221223
---
222224

223-
* Syntax: **"http_log_json_kafka_log_level** _numeric_log_level_;
225+
* Syntax: **http_log_json_kafka_log_level** _numeric_log_level_;
224226
* Default: 6
225227
* Context: http main
226228

227229
---
228230

229-
* Syntax: **"http_log_json_kafka_max_retries** _numeric_;
231+
* Syntax: **http_log_json_kafka_max_retries** _numeric_;
230232
* Default: 0
231233
* Context: http main
232234

233235
---
234236

235-
* Syntax: **"http_log_json_kafka_buffer_max_messages** _numeric_;
237+
* Syntax: **http_log_json_kafka_buffer_max_messages** _numeric_;
236238
* Default: 100000
237239
* Context: http main
238240

239241
---
240242

241-
* Syntax: **"http_log_json_kafka_backoff_ms** _numeric_;
243+
* Syntax: **http_log_json_kafka_backoff_ms** _numeric_;
242244
* Default: 10
243245
* Context: http main
244246

245247
---
246248

247-
* Syntax: **"http_log_json_kafka_partition** _partition_;
249+
* Syntax: **http_log_json_kafka_partition** _partition_;
248250
* Default: RD_KAFKA_PARTITION_UA
249251
* Context: http local
250252

253+
---
254+
255+
* Syntax: **http_log_json_req_body_limit** _size_;
256+
* Default: 512
257+
* Context: local
258+
259+
Limits the body size to log.
260+
Argument is a size string. May be 1k or 1M, but avoid this!
261+
262+
### Variables
263+
264+
#### $http_log_json_req_headers;
265+
266+
Creates a json object with all request headers.
267+
268+
Example:
269+
270+
```
271+
"req": {
272+
"headers": {
273+
"Host": "localhost",
274+
"User-Agent": "curl/7.52.1",
275+
"Accept": "*/*"
276+
}
277+
}
278+
```
279+
280+
#### $http_log_json_req_body;
281+
282+
Log request body encoded as base64.
283+
It requires proxy_pass configuration at logging location.
284+
285+
Example:
286+
287+
```
288+
"req": {
289+
"body": "Zm9v"
290+
}
291+
```
292+
#### $http_log_json_resp_headers;
293+
294+
Creates a json object with available response headers.
295+
296+
Example:
251297

298+
```
299+
resp": {
300+
"headers": {
301+
"Last-Modified": "Sat, 01 Apr 2017 13:34:28 GMT",
302+
"ETag": "\"58dfac64-12\"",
303+
"X-Foo": "bar",
304+
"Accept-Ranges": "bytes"
305+
}
306+
```
252307

253308
### Build
254309

@@ -368,9 +423,9 @@ Percentage of the requests served within a certain time (ms)
368423
99% 1
369424
100% 115 (longest request)
370425
371-
real 1m36.057s
372-
user 0m5.390s
373-
sys 1m22.040s
426+
real 1m36.057s
427+
user 0m5.390s
428+
sys 1m22.040s
374429
375430
$ wc -l /tmp/1M.log
376431
1000000 /tmp/1M.log
@@ -435,7 +490,8 @@ Percentage of the requests served within a certain time (ms)
435490
99% 2
436491
100% 1022 (longest request)
437492
438-
real 1m43.328s
439-
user 0m5.770s
440-
sys 1m21.380s
493+
real 1m43.328s
494+
user 0m5.770s
495+
sys 1m21.380s
441496
```
497+

config

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@ ngx_module_incs=$ngx_addon_dir/src
33

44
HTTP_MODULES="$HTTP_MODULES ngx_http_log_json_module"
55

6+
HTTP_FILTER_MODULES="$HTTP_FILTER_MODULES ngx_http_log_json_filter_module"
7+
68
CORE_INCS="$CORE_INCS $ngx_module_incs"
7-
NGX_ADDON_SRCS="$NGX_ADDON_SRCS \
8-
$ngx_addon_dir/src/ngx_http_log_json_kafka.c \
9-
$ngx_addon_dir/src/ngx_http_log_json_str.c \
10-
$ngx_addon_dir/src/ngx_http_log_json_module.c \
11-
$ngx_addon_dir/src/ngx_http_log_json_text.c "
9+
10+
NGX_ADDON_SRCS="$NGX_ADDON_SRCS \
11+
$ngx_addon_dir/src/ngx_http_log_json_kafka.c \
12+
$ngx_addon_dir/src/ngx_http_log_json_str.c \
13+
$ngx_addon_dir/src/ngx_http_log_json_text.c \
14+
$ngx_addon_dir/src/ngx_http_log_json_variables.c \
15+
$ngx_addon_dir/src/ngx_http_log_json_module.c \
16+
$ngx_addon_dir/src/ngx_http_log_json_filter_module.c \
17+
"
18+
1219
CORE_LIBS="$CORE_LIBS -ljansson -lrdkafka"

docker/nginx-http-log-json/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LABEL maintainer "[email protected]"
55
# Build arguments
66
ARG DEBIAN_REPO_HOST=httpredir.debian.org
77
ARG GIT_LOCATION=https://github.com/fooinha/nginx-http-log-json.git
8-
ARG GIT_BRANCH=feature/0.0.3/module/lod
8+
ARG GIT_BRANCH=master
99

1010
# Mirror to my location
1111
RUN echo "deb http://${DEBIAN_REPO_HOST}/debian sid main" > /etc/apt/sources.list

docs/use-case-kafka-logs.png

5.37 KB
Loading

0 commit comments

Comments
 (0)