config in pipeline/logstash.conf
:
filter {
grok {
match => {
"message" => [
"\[%{TIMESTAMP_ISO8601:timestamp}\] \[%{LOGLEVEL:level}\] \[%{PATH:path}:%{POSINT:line}\] \[%{WORD:node}\] \[%{GREEDYDATA:message}\]",
"%{COMBINEDAPACHELOG}"
]
}
overwrite => [ "message" ]
}
urldecode {
field => "request"
}
}
examples:
[2018-10-19 15:22:30.709] [INFO] [/build/app.js:42] [master] [POST:/app/games/2/posts/25571/relationships 400 11.250 ms 221.213.146.164 {"openid":"oAl2A0i_3kpAodDyAR53CZFVgX-g"}]
140.207.54.75 - - [19/Oct/2018:15:38:14 +0800] "POST /wx56b01188481383cb/callback?signature=2688cea83553f2cb6f9c2b76eb3381108cca0f21×tamp=1539934693&nonce=1210898241&openid=oAl2A0pnnLJEtF1fb1rNr69Zsa6s&encrypt_type=aes&msg_signature=54a361c14e8f73a81ca8189189b42b78c0ea4c5f HTTP/1.1" 200 7 "-" "Mozilla/4.0" "-"
result in debugger:
{
"path": "/build/app.js",
"node": "master",
"level": "INFO",
"line": "42",
"message": "POST:/app/games/2/posts/25571/relationships 400 11.250 ms 221.213.146.164 {\"openid\":\"oAl2A0i_3kpAodDyAR53CZFVgX-g\"}",
"timestamp": "2018-10-19 15:22:30.709"
}
{
"request": "/wx56b01188481383cb/callback?signature=2688cea83553f2cb6f9c2b76eb3381108cca0f21×tamp=1539934693&nonce=1210898241&openid=oAl2A0pnnLJEtF1fb1rNr69Zsa6s&encrypt_type=aes&msg_signature=54a361c14e8f73a81ca8189189b42b78c0ea4c5f",
"agent": "\"Mozilla/4.0\"",
"auth": "-",
"ident": "-",
"verb": "POST",
"referrer": "\"-\"",
"response": "200",
"bytes": "7",
"clientip": "140.207.54.75",
"httpversion": "1.1",
"timestamp": "19/Oct/2018:15:38:14 +0800"
}
data in kibana:
NOT CHANGED
{
"_index": "filebeat-6.4.2-2018.10.19",
"_type": "doc",
"_id": "Ey5Fi2YB_U2Lw1whTETO",
"_version": 1,
"_score": null,
"_source": {
"@timestamp": "2018-10-19T07:41:04.517Z",
"source": "/var/lib/docker/containers/64e370d4ad3278ca5a3c7f790b81d17aa509bd1b5b54c31c942ed74e6b51f855/64e370d4ad3278ca5a3c7f790b81d17aa509bd1b5b54c31c942ed74e6b51f855-json.log",
"offset": 26716807,
"stream": "stdout",
"prospector": {
"type": "docker"
},
"input": {
"type": "docker"
},
"beat": {
"name": "iZbp13wzrvhq9vui56o0jqZ",
"hostname": "iZbp13wzrvhq9vui56o0jqZ",
"version": "6.4.2"
},
"host": {
"name": "iZbp13wzrvhq9vui56o0jqZ"
},
"message": "[2018-10-19 15:41:04.515] [INFO] [/build/common/schedule-job-manager.js:49] [master] [定时job:CHECK_DIST 完成]",
"docker": {
"container": {
"image": "parsec-tech/game-0008",
"name": "game0008_game-0008_1",
"id": "64e370d4ad3278ca5a3c7f790b81d17aa509bd1b5b54c31c942ed74e6b51f855",
"labels": {
"com": {
"docker": {
"compose": {
"project": "game0008",
"service": "game-0008",
"version": "1.20.0-rc2",
"config-hash": "f2001599317358200942f3a5511a92106cba9b45b9ce811c282c6316b755c37d",
"container-number": "1",
"oneoff": "False"
}
}
}
}
}
}
},
"fields": {
"@timestamp": [
"2018-10-19T07:41:04.517Z"
]
},
"highlight": {
"docker.container.image": [
"@kibana-highlighted-field@parsec-tech/game-0008@/kibana-highlighted-field@"
]
},
"sort": [
1539934864517
]
}
{
"_index": "filebeat-6.4.2-2018.10.19",
"_type": "doc",
"_id": "Hy5Fi2YB_U2Lw1whYkQ2",
"_version": 1,
"_score": null,
"_source": {
"@timestamp": "2018-10-19T07:41:10.524Z",
"prospector": {
"type": "docker"
},
"host": {
"name": "iZbp13wzrvhq9vui56o0jqZ"
},
"beat": {
"version": "6.4.2",
"name": "iZbp13wzrvhq9vui56o0jqZ",
"hostname": "iZbp13wzrvhq9vui56o0jqZ"
},
"source": "/var/lib/docker/containers/3cdc915d9e8cd82a2bac66523c5902214048c8821f5b7d47834cec74a3b0af0b/3cdc915d9e8cd82a2bac66523c5902214048c8821f5b7d47834cec74a3b0af0b-json.log",
"offset": 17352916,
"message": "58.251.80.52 - - [19/Oct/2018:15:41:10 +0800] \"POST /wxa040c2edf31a93d0/callback?signature=ba57cc48819d635a8e1a6c34183e198541c16b57×tamp=1539934870&nonce=1100722667&openid=o0SUiwsUpGtuvZlAy9aJtnnbH_ac&encrypt_type=aes&msg_signature=49f9eef49a3bb36a4da75b3c7c40b8364ad54493 HTTP/1.1\" 200 7 \"-\" \"Mozilla/4.0\" \"-\"",
"input": {
"type": "docker"
},
"stream": "stdout",
"docker": {
"container": {
"id": "3cdc915d9e8cd82a2bac66523c5902214048c8821f5b7d47834cec74a3b0af0b",
"image": "nginx",
"name": "nginx"
}
}
},
"fields": {
"@timestamp": [
"2018-10-19T07:41:10.524Z"
]
},
"highlight": {
"docker.container.image": [
"@kibana-highlighted-field@nginx@/kibana-highlighted-field@"
]
},
"sort": [
1539934870524
]
}