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
nginx: upgrade to nginx 1.11.10 support
module: rename to formal name ngx_http_log_json
module: parse recipe with pcre regex
module: refactoring functions
config: support array values
config: support literal boolean values
config: support literal null values
config: if condition argument
tests: initial unit tests
build: travis integration
nginx module for advanced per location logging - aka kasha (🍲)
3
+
nginx http module for logging in custom json format - aka kasha (🍲)
5
4
6
5
## Description
7
6
8
7
This module adds to nginx the ability of advanced JSON logging of HTTP requests per location.
8
+
9
9
It's possible to log to a destination ouput any request made to a specific nginx location.
10
+
10
11
The output format is configurable.
11
12
13
+
It also allows to log complex and multi-level JSON documents.
14
+
15
+
It supports logging to text file or to a kafka topic.
16
+
17
+
## Use cases
18
+
19
+
That are many use cases.
20
+
21
+
Many things can be done by using the access log data.
22
+
23
+
Having it in JSON format makes easier for integration with other platforms and applications.
24
+
25
+
A quick example:
26
+
27
+

28
+
29
+
12
30
### Configuration
13
31
14
-
Each logging configuration is based on a kasha_recipe. (🍲)
32
+
Each logging configuration is based on a http_log_json_format. (🍲)
15
33
16
-
A kasha recipe is a ';' separated list of items to include in the logging preparation.
34
+
A http_log_json_format is a ';' separated list of items to include in the logging preparation.
17
35
18
36
The left hand side part of item will be the JSON Path for the variable name
19
-
The left hand side part can be prefixed with 's:', 'i:'or 'r:', so the JSON encoding type can be controlled.
37
+
The left hand side part can be prefixed with 's:', 'i:', 'r:', 'b:' or 'n:', so, the JSON encoding type can be controlled.
20
38
21
39
* 's:' - JSON string ( default )
22
40
* 'i:' - JSON integer
23
41
* 'r:' - JSON real
42
+
* 'b:' - JSON boolean
43
+
* 'n:' - JSON null
44
+
45
+
Additional prefix:
46
+
47
+
* 'a:' - JSON Array - MUST be used before other prefixes. All keys with same name and defined as array will be its values grouped together in an array. ( see example below )
24
48
25
49
26
50
The right hand side will be the variable's name or literal value.
27
51
For this, known or previously setted variables, can be used by using the '$' before name.
28
52
29
53
Common HTTP nginx builtin variables like $uri, or any other variable set by other handler modules can be used.
30
54
31
-
The output is sent to the location specified by the first kasha_recipe argument.
55
+
The output is sent to the location specified by the first http_log_json_format argument.
32
56
The possible output locations are:
33
57
34
58
* "file:" - The logging location will be a local filesystem file.
@@ -40,7 +64,7 @@ The possible output locations are:
40
64
##### A simple configuration example
41
65
42
66
```yaml
43
-
kasha_recipe file:/tmp/log '
67
+
http_log_json_format file:/tmp/log '
44
68
src.ip $remote_addr;
45
69
src.port $remote_port;
46
70
dst.ip $server_addr;
@@ -49,12 +73,15 @@ The possible output locations are:
49
73
r:_real 1.1;
50
74
i:_int 2016;
51
75
i:_status $status;
76
+
b:_notrack false;
52
77
_literal root;
53
78
comm.proto http;
54
79
comm.http.method $request_method;
55
80
comm.http.path $uri;
56
81
comm.http.host $host;
57
82
comm.http.server_name $server_name;
83
+
a:i:list 1;
84
+
a:list string;
58
85
';
59
86
```
60
87
@@ -68,6 +95,7 @@ To ease reading, it's shown here formatted with newlines.
68
95
"_literal": "root",
69
96
"_real": 1.1,
70
97
"_status": 200,
98
+
"_notrack": false,
71
99
"comm": {
72
100
"http": {
73
101
"host": "localhost",
@@ -84,7 +112,11 @@ To ease reading, it's shown here formatted with newlines.
84
112
"src": {
85
113
"ip": "127.0.0.1",
86
114
"port": "52136"
87
-
}
115
+
},
116
+
"list": [
117
+
1,
118
+
"string"
119
+
]
88
120
}
89
121
```
90
122
@@ -100,7 +132,7 @@ To ease reading, it's shown here formatted with newlines.
100
132
return "";
101
133
}';
102
134
103
-
kasha_recipe file:/tmp/log '
135
+
http_log_json_format file:/tmp/log '
104
136
comm.http.server_name $server_name;
105
137
perl.bar $bar;
106
138
';
@@ -125,7 +157,7 @@ To ease reading, it's shown here formatted with newlines.
0 commit comments