Hello,
I'm trying to parse docker json-file output to Logstash using Filebeat and to break the message log into fields.
Currently, this is what I can parse into Kibana:
{
"_index": "filebeat-2017.12.19",
"_type": "doc",
"_id": "pr50bmABIujUTb2Ryv8M",
"_version": 1,
"_score": null,
"_source": {
"offset": 6761353,
"log": "\u001b[0m\u001b[0m11:07:12.951 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 54) WFLYUT0021: Registered web context: /rest\n",
"prospector": {
"type": "log"
},
"source": "/var/lib/docker/containers/7688c378a4de513a8c5e587843512476ea996700e93a792e71c5962a190bb779/7688c378a4de513a8c5e587843512476ea996700e93a792e71c5962a190bb779-json.log",
"message": "{\"log\":\"\\u001b[0m\\u001b[0m11:07:12.951 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 54) WFLYUT0021: Registered web context: /rest\\n\",\"stream\":\"stdout\",\"time\":\"2017-12-19T11:07:12.952311089Z\"}",
"docker": {
"container": {
"name": "wildfly01",
"image": "dockerepos.dom.local:5000/wildfly:10.0.0.Final",
"id": "7688c378a4de513a8c5e587843512476ea996700e93a792e71c5962a190bb779",
"labels": {
"license": "GPLv2",
"build-date": "20170801",
"vendor": "CentOS"
}
}
},
"tags": [
"beats_input_codec_plain_applied",
"_grokparsefailure",
"_jsonparsefailure"
],
"@message": {
"time": "2017-12-19T11:07:12.952311089Z",
"log": "\u001b[0m\u001b[0m11:07:12.951 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 54) WFLYUT0021: Registered web context: /rest\n",
"stream": "stdout"
},
"@timestamp": "2017-12-19T11:07:14.787Z",
"stream": "stdout",
"@version": "1",
"beat": {
"name": "server_devenv01",
"hostname": "server_devenv01",
"version": "6.0.1"
},
"host": "server_devenv01",
"topic": "Local-Dev-wildfly",
"time": "2017-12-19T11:07:12.952311089Z"
},
"fields": {
"@message.time": [
"2017-12-19T11:07:12.952Z"
],
"@timestamp": [
"2017-12-19T11:07:14.787Z"
]
},
"sort": [
1513681634787
]
}
I want to break the @message field into some other fields, by the following pattern:
%{DATE:date} %{TIME:time} %{LOGLEVEL:loglevel}%{SPACE} [(?[^]]+)] ((?[^]]+))%{SPACE} %{GREEDYDATA:message}
Currently I have the following configurations:
filebeat.yml:
filebeat.prospectors:
- type: log
enabled: true
paths:
- '/var/lib/docker/containers/*/*.log'
processors:
- add_docker_metadata: ~
fields:
topic: Local-Dev-wildfly
fields_under_root: true
multiline.pattern: '^\[[:space:]]+|]$'
multiline.match: after
/etc/logstash/conf.d/10-filter.conf
filter {
json {
source => "message"
target => "@message"
}
json {
source => "message"
}
grok {
match => { '@message' => '%{DATE:date} %{TIME:time} %{LOGLEVEL:loglevel}%{SPACE} [(?[^]]+)] ((?[^]]+))%{SPACE} %{GREEDYDATA:message}' }
}
}
How can I break the @message log to a specific fields (LOGLEVEL, LOGGER, THREAD and etc...?
Thanks!