Hi,
I am trying to configure Filebeat to parse json logs produced by one of my service. Everything works find if log message has one level properties only. But if I include custom payload(nested object) Filebeat always fails to parse it. I have already processed these log message via Logstash without any problem but want to migrate to Filebeat.
filebeat.yml
filebeat.inputs:
- type: log
enabled: true
paths:
- e:\Service\logs\*
json.keys_under_root: true
json.add_error_key: true
#processors:
# - decode_json_fields:
# fields: ["jsonmessage"]
# process_array: true
# max_depth: 6
# overwrite_keys: true
# when:
# regexp:
# jsonmessage: '^\{'
filebeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
setup.template.enabled: false
setup.template.settings:
index.number_of_shards: 3
setup.kibana:
output.elasticsearch:
hosts: ["localhost:9200"]
index: "logs-%{[beat.version]}-%{+yyyy.MM}"
indices:
- index: "%{[logindexprefix]}-%{+yyyy.MM}"
when.regexp:
logindexprefix: .*
log record example
{"date":"2018-07-16T18:02:22.4913711+01:00","level":"INFO","logger":"TcpServer","thread":"7","ndc":"(null)","message":"TEST MESSAGE","appname":"Service.DEVTEST","appversion":"1.1.0.6478","executable":"Service.exe","logindexprefix":"myservice","context":"SERVICE","method":"Run","connection":"(null)","imei":"(null)","payload":{"id":2,"msg":"Test message 2"}}
I've tried to POST above json directly to the index by using Kibana Dev Tools and it works.
Filebeat output:
2018-07-16T18:03:33.748+0300 WARN elasticsearch/client.go:502 Cannot index event publisher.Event{Content:beat.Event{Timestamp:time.Time{wall:0xbecb4ad11141ea54, ext:133830301, loc:(*time.Location)(0x16f3580)}, Meta:common.MapStr(nil), Fields:common.MapStr{"host":common.MapStr{"name":"DEVELOPER"}, "executable":"Service.exe", "payload":common.MapStr{"id":1, "msg":"Test message"}, "message":"TEST MESSAGE", "logindexprefix":"myservice", "context":"SERVICE", "logger":"TcpServer", "appversion":"1.1.0.6478", "prospector":common.MapStr{"type":"log"}, "input":common.MapStr{"type":"log"}, "beat":common.MapStr{"name":"DEVELOPER", "hostname":"DEVELOPER", "version":"6.3.1"}, "imei":"(null)", "date":"2018-07-16T18:00:52.6016467+03:00", "offset":290222, "connection":"(null)", "ndc":"(null)", "source":"e:\\Service\\logs\\logfile", "appname":"Service.DEVTEST", "level":"INFO", "method":"Run", "thread":"8"}, Private:file.State{Id:"", Finished:false, Fileinfo:(*os.fileStat)(0xc042432a80), Source:"e:\\Service\\logs\\logfile", Offset:290637, Timestamp:time.Time{wall:0xbecb4ad1105a6530, ext:118657401, loc:(*time.Location)(0x16f3580)}, TTL:-1, Type:"log", Meta:map[string]string{}, FileStateOS:file.StateOS{IdxHi:0x1f0000, IdxLo:0x48a43, Vol:0x6e9748c}}}, Flags:0x1} (status=400): {"type":"mapper_parsing_exception","reason":"failed to parse [payload]","caused_by":{"type":"illegal_state_exception","reason":"Can't get text on a START_OBJECT at 1:593"}}
I also tried to serialize nested object to "jsonmessage" field and parse it via processor(commented lines in .yml file) but without any success.
Any help would be appreciated.