elasticsearch - Logstash is not converting correctly in JSON -


following json log file

[     {         "error_message": " failed line input file (end of file?).",          "type": "error",          "line_no": "2625",          "file": "gtfplaintext.c",          "time": "17:40:02",          "date": "01/07/16",          "error_code": "gtf-00014"     },      {         "error_message": " bad gtf plain text file header or footer line. ",          "type": "error",          "line_no": "2669",          "file": "gtfplaintext.c",          "time": "17:40:02",          "date": "01/07/16",          "error_code": "gtf-00004"     },      {         "error_message": " '???' ",          "type": "error",          "line_no": "2670",          "file": "gtfplaintext.c",          "time": "17:40:02",          "date": "01/07/16",          "error_code": "gtf-00005"     },      {         "error_message": " failed find 'event source'/'product detail' records event source '3025188506' host event type 1 valid",          "type": "error",          "line_no": "0671",          "file": "rguide.cc",          "time": "15:43:48",          "date": "06/07/16",          "error_code": "rguide-00033"     } ] 

according understanding log in json, not need filter section in logstash configuration. following logstash config

input {   file{     path => "/home/ishan/sf_shared/log_json.json"     start_position => "beginning"     codec => "json"   } } 

and output configuration is

output {   elasticsearch {     hosts => ["localhost:9200"]     sniffing => true     manage_template => false     index => "%{[@metadata][beat]}-%{+yyyy.mm.dd}"     document_type => "%{[@metadata][type]}"   }   stdout { codec => rubydebug } } 

but seems data not going es, not able see data when query index. missing?

i think problem json codec expects full json message on 1 line , won't work message on multiple lines.

a possible work around use multiline codex , use json filter.
configuration multiline codec be:

multiline {   pattern => "]"   negate => "true"   => "next" } 

all lines not begin ] regrouped next line, you'll have 1 full json document give json filter.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -