I need to parse and have all the JSON object in one message but it is splitting into different messages as you can see in stdout below
JSON:
[
{
"SOURCE": "Source A",
"Model": "ModelABC",
"Qty": "3"
},
{
"SOURCE": "Source B",
"Model": "MoBC",
"Qty": "31"
},
{
"SOURCE": "Source C",
"Model": "MoBCSss",
"Qty": "3qq"
}
]
but getting error:
exception=>#<LogStash::Json::ParserError: Unexpected character (':' (code 58)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
here is the full logstash config file:
input {
file {
path => "/usr/share/logstash/sample-log/Test-Log-For-Kibana.json"
start_position => "beginning"
codec => "plain"
}
}
filter {
json { source =>"message"
target => "log"
}
}
output {
stdout { codec => rubydebug }
elasticsearch {
hosts => "elasticsearch:9200"
user => "elastic"
password => "changeme"
}
}
stacktrace and stdout:
logstash_1 | [2020-07-14T21:22:34,209][WARN ][logstash.filters.json ] Error parsing json {:source=>"message", :raw=>"]{\r", :exception=>#<LogStash::Json::ParserError: Unexpected c"; line: 1, column: 0])ed '}' (for root starting at [Source: (byte[])"]{ "; line: 1, column: 2]>}Source: (byte[])"]{ logstash_1 | [2020-07-14T21:22:34,212][WARN ][logstash.filters.json ] Error parsing json {:source=>"message", :raw=>" \"time\": \"[30/Jul/2017:17:21:45 +0000]\",\r", :exception=>#<LogStash::Json::ParserError: Unexpected character (':' (code 58)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') "; line: 1, column: 12]>}ource: (byte[])" "time": "[30/Jul/2017:17:21:45 +0000]", logstash_1 | [2020-07-14T21:22:34,214][WARN ][logstash.filters.json ] Error parsing json {:source=>"message", :raw=>" \"host\": \"my.host.local\",\r", :exception=>#<LogStash::Json::ParserError: Unexpected character (':' (code 58)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') "; line: 1, column: 12]>}ource: (byte[])" "host": "my.host.local", logstash_1 | [2020-07-14T21:22:34,217][WARN ][logstash.filters.json ] Error parsing json {:source=>"message", :raw=>" \"remoteIP\": \"192.168.2.1\",\r", :exception=>#<LogStash::Json::ParserError: Unexpected character (':' (code 58)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') "; line: 1, column: 16]>}ource: (byte[])" "remoteIP": "192.168.2.1", logstash_1 | [2020-07-14T21:22:34,219][WARN ][logstash.filters.json ] Error parsing json {:source=>"message", :raw=>" \"query\": \"\",\r", :exception=>#<LogStash::Json::ParserError: Unexpected character (':' (code 58)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') "; line: 1, column: 13]>}ource: (byte[])" "query": "", logstash_1 | [2020-07-14T21:22:34,223][WARN ][logstash.filters.json ] Error parsing json {:source=>"message", :raw=>" \"status\": \"200\",\r", :exception=>#<LogStash::Json::ParserError: Unexpected character (':' (code 58)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') "; line: 1, column: 14]>}ource: (byte[])" "status": "200", logstash_1 | [2020-07-14T21:22:34,225][WARN ][logstash.filters.json ] Error parsing json {:source=>"message", :raw=>" \"referer\": \"-\"\r", :exception=>#<LogStash::Json::ParserError: Unexpected character (':' (code 58)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') "; line: 1, column: 15]>}ource: (byte[])" "referer": "-" logstash_1 | [2020-07-14T21:22:34,224][WARN ][logstash.filters.json ] Error parsing json {:source=>"message", :raw=>" \"request\": \"/index.html\",\r", :exception=>#<LogStash::Json::ParserError: Unexpected character (':' (code 58)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') "; line: 1, column: 15]>}ource: (byte[])" "request": "/index.html", logstash_1 | [2020-07-14T21:22:34,228][WARN ][logstash.filters.json ] Error parsing json {:source=>"message", :raw=>" \"method\": \"GET\",\r", :exception=>#<LogStash::Json::ParserError: Unexpected character (':' (code 58)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') "; line: 1, column: 14]>}ource: (byte[])" "method": "GET", logstash_1 | [2020-07-14T21:22:34,236][WARN ][logstash.filters.json ] Error parsing json {:source=>"message", :raw=>" \"userAgent\": \"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; YTB720; GTB7.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)\",\r", :exception=>#<LogStash::Json::ParserError: Unexpected character (':' (code 58)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') logstash_1 | at [Source: (byte[])" "userAgent": "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; YTB720; GTB7.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3"; line: 1, column: 17]>}5.30729)", logstash_1 | { logstash_1 | "host" => "d9e25305bbed", logstash_1 | "message" => " \"time\": \"[30/Jul/2017:17:21:45 +0000]\",\r", logstash_1 | "@version" => "1", logstash_1 | "@timestamp" => 2020-07-14T21:22:34.088Z, logstash_1 | "path" => "/usr/share/logstash/sample-log/Test-Log-For-Kibana.json", logstash_1 | "tags" => [ logstash_1 | [0] "_jsonparsefailure" logstash_1 | ] logstash_1 | } logstash_1 | { logstash_1 | "host" => "d9e25305bbed", logstash_1 | "message" => " \"host\": \"my.host.local\",\r", logstash_1 | "@version" => "1", logstash_1 | "@timestamp" => 2020-07-14T21:22:34.092Z, logstash_1 | "path" => "/usr/share/logstash/sample-log/Test-Log-For-Kibana.json", logstash_1 | "tags" => [ logstash_1 | [0] "_jsonparsefailure" logstash_1 | ] logstash_1 | } logstash_1 | { logstash_1 | "host" => "d9e25305bbed", logstash_1 | "message" => " \"query\": \"\",\r", logstash_1 | "@version" => "1", logstash_1 | "@timestamp" => 2020-07-14T21:22:34.093Z, logstash_1 | "path" => "/usr/share/logstash/sample-log/Test-Log-For-Kibana.json", logstash_1 | "tags" => [ logstash_1 | [0] "_jsonparsefailure" logstash_1 | ] logstash_1 | } logstash_1 | { logstash_1 | "host" => "d9e25305bbed", logstash_1 | "message" => " \"status\": \"200\",\r", logstash_1 | "@version" => "1", logstash_1 | "@timestamp" => 2020-07-14T21:22:34.099Z, logstash_1 | "path" => "/usr/share/logstash/sample-log/Test-Log-For-Kibana.json", logstash_1 | "tags" => [ logstash_1 | [0] "_jsonparsefailure" logstash_1 | ] logstash_1 | } logstash_1 | { logstash_1 | "host" => "d9e25305bbed", logstash_1 | "message" => " \"referer\": \"-\"\r", logstash_1 | "@version" => "1", logstash_1 | "@timestamp" => 2020-07-14T21:22:34.106Z, logstash_1 | "path" => "/usr/share/logstash/sample-log/Test-Log-For-Kibana.json", logstash_1 | "tags" => [ logstash_1 | [0] "_jsonparsefailure" logstash_1 | ] logstash_1 | } logstash_1 | { logstash_1 | "host" => "d9e25305bbed", logstash_1 | "message" => "]{\r", logstash_1 | "@version" => "1", logstash_1 | "@timestamp" => 2020-07-14T21:22:34.085Z, logstash_1 | "path" => "/usr/share/logstash/sample-log/Test-Log-For-Kibana.json", logstash_1 | "tags" => [ logstash_1 | [0] "_jsonparsefailure" logstash_1 | ] logstash_1 | } logstash_1 | { logstash_1 | "host" => "d9e25305bbed", logstash_1 | "message" => " \"remoteIP\": \"192.168.2.1\",\r", logstash_1 | "@version" => "1", logstash_1 | "@timestamp" => 2020-07-14T21:22:34.091Z, logstash_1 | "path" => "/usr/share/logstash/sample-log/Test-Log-For-Kibana.json", logstash_1 | "tags" => [ logstash_1 | [0] "_jsonparsefailure" logstash_1 | ] logstash_1 | } logstash_1 | { logstash_1 | "host" => "d9e25305bbed", logstash_1 | "message" => " \"request\": \"/index.html\",\r", logstash_1 | "@version" => "1", logstash_1 | "@timestamp" => 2020-07-14T21:22:34.092Z, logstash_1 | "path" => "/usr/share/logstash/sample-log/Test-Log-For-Kibana.json", logstash_1 | "tags" => [ logstash_1 | [0] "_jsonparsefailure" logstash_1 | ] logstash_1 | } logstash_1 | { logstash_1 | "host" => "d9e25305bbed", logstash_1 | "message" => " \"method\": \"GET\",\r", logstash_1 | "@version" => "1", logstash_1 | "@timestamp" => 2020-07-14T21:22:34.098Z, logstash_1 | "path" => "/usr/share/logstash/sample-log/Test-Log-For-Kibana.json", logstash_1 | "tags" => [ logstash_1 | [0] "_jsonparsefailure" logstash_1 | ] logstash_1 | } logstash_1 | { logstash_1 | "host" => "d9e25305bbed", logstash_1 | "message" => " \"userAgent\": \"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; YTB720; GTB7.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)\",\r", logstash_1 | "@version" => "1", logstash_1 | "@timestamp" => 2020-07-14T21:22:34.100Z, logstash_1 | "path" => "/usr/share/logstash/sample-log/Test-Log-For-Kibana.json", logstash_1 | "tags" => [ logstash_1 | [0] "_jsonparsefailure" logstash_1 | ] logstash_1 | }