|
8 | 8 | pattern ^nginx |
9 | 9 | tag logs.kubernetes.nginx |
10 | 10 | </rule> |
11 | | - # Add a tag for your application |
12 | | - <rule> |
13 | | - key $.kubernetes.container_name |
14 | | - pattern ^your-application |
15 | | - tag logs.kubernetes.yourapplication |
16 | | - </rule> # Catch all (have to actually change the tag (add "logs.") otherwise there is an infinite loop) |
| 11 | + # # Add a tag for your application - enable this and the blocks below if you want fluentd to manually control the structure of your logs |
| 12 | + # # Otherwise it will just parse out the structured json data and send it to elasticsearch |
| 13 | + # <rule> |
| 14 | + # key $.kubernetes.container_name |
| 15 | + # pattern ^your-application |
| 16 | + # tag logs.kubernetes.yourapplication |
| 17 | + # </rule> # Catch all (have to actually change the tag (add "logs.") otherwise there is an infinite loop) |
17 | 18 | <rule> |
18 | 19 | key log |
19 | 20 | pattern ^(.*)$ |
20 | 21 | tag logs.${tag} |
21 | 22 | </rule> |
22 | 23 | </match> |
23 | 24 |
|
24 | | - # This allows us to parse log lines that have json separately, but still keep the unstructured ones |
25 | | - <match {logs.kubernetes.yourapplication}> |
26 | | - @type rewrite_tag_filter |
27 | | - # Add a tag for messages that didn't have parseable json |
28 | | - <rule> |
29 | | - key log |
30 | | - pattern /"message" *: *\{/ |
31 | | - tag ${tag}.hasJson |
32 | | - </rule> |
33 | | - # Catch all |
34 | | - <rule> |
35 | | - key log |
36 | | - pattern ^(.*)$ |
37 | | - tag ${tag}.noJson |
38 | | - </rule> |
39 | | - </match> |
| 25 | + # # This allows us to parse log lines that have json separately, but still keep the unstructured ones |
| 26 | + # <match {logs.kubernetes.yourapplication}> |
| 27 | + # @type rewrite_tag_filter |
| 28 | + # # Add a tag for messages that didn't have parseable json |
| 29 | + # <rule> |
| 30 | + # key log |
| 31 | + # pattern /"message" *: *\{/ |
| 32 | + # tag ${tag}.hasJson |
| 33 | + # </rule> |
| 34 | + # # Catch all |
| 35 | + # <rule> |
| 36 | + # key log |
| 37 | + # pattern ^(.*)$ |
| 38 | + # tag ${tag}.noJson |
| 39 | + # </rule> |
| 40 | + # </match> |
40 | 41 |
|
41 | 42 |
|
42 | 43 | # Remove fields here we don't care to log |
|
45 | 46 | remove_keys $.docker.container_id, $.kubernetes.master_url, $.kubernetes.pod_id, $.kubernetes.namespace_id |
46 | 47 | </filter> |
47 | 48 |
|
48 | | - # Separate out messages with json into another key called data |
49 | | - # message":{ |
50 | | - <filter logs.kubernetes.*.hasJson> |
51 | | - @type record_transformer |
52 | | - enable_ruby |
53 | | - <record> |
54 | | - log ${record["log"].gsub(/"message" *: *\{/, '"data": {')} |
55 | | - </record> |
56 | | - </filter> |
| 49 | + # # Separate out messages with json into another key called data |
| 50 | + # # message":{ |
| 51 | + # <filter logs.kubernetes.*.hasJson> |
| 52 | + # @type record_transformer |
| 53 | + # enable_ruby |
| 54 | + # <record> |
| 55 | + # log ${record["log"].gsub(/"message" *: *\{/, '"data": {')} |
| 56 | + # </record> |
| 57 | + # </filter> |
57 | 58 |
|
58 | 59 | # Parse nested fields as json |
59 | 60 | <filter logs.kubernetes.**> |
|
62 | 63 | key_name log |
63 | 64 | reserve_data true |
64 | 65 | remove_key_name_field true |
65 | | - inject_key_prefix log. |
| 66 | + # inject_key_prefix log. |
66 | 67 |
|
67 | 68 | <parse> |
68 | 69 | @type multi_format |
|
101 | 102 | http.request.bytes ${record["log.request_length"].to_i} |
102 | 103 | http.response.bytes ${record["log.bytes_sent"].to_i} |
103 | 104 | http.response.status_code ${record["log.status"].to_i} |
104 | | - trace.id ${record["log.http_x_correlation_id"]} |
| 105 | + trace.id ${record["log.request_id"]} |
105 | 106 | client.ip ${record["log.remote_addr"]} |
106 | 107 | url.path ${record["log.path"]} |
107 | 108 | url.query ${record["log.request_query"]} |
|
110 | 111 | </record> |
111 | 112 | </filter> |
112 | 113 |
|
113 | | - # Reformat your application logs into ECS format |
| 114 | + # # Reformat your application logs into ECS format |
114 | 115 | # <filter logs.kubernetes.*.hasJson> |
115 | 116 | # @id application-to-ecs-format |
116 | 117 | # @type record_transformer |
|
122 | 123 | # </filter> |
123 | 124 |
|
124 | 125 |
|
125 | | - # Uncomment these to make debugging easier by printing to stdout in fluentd |
| 126 | + # # Uncomment these to make debugging easier by printing to stdout in fluentd |
126 | 127 | # <match logs.kubernetes.nginx> |
127 | 128 | # @type stdout |
128 | 129 | # </match> |
|
0 commit comments