Yes, i know this is the info message, what i mean is that logstash doesnt do anything, it hangs at that point.
I have noticed that this happens when i put the json text in one line. If i format the json file as i pasted in the original post, then, it is when i have the errors. THis is what i have with your output:
[2022-04-28T14:39:12,215][WARN ][logstash.filters.json ][main][3fb410f4c4226c62d48f6393d19008a691ac547d52f3b83f0d9a28ff8bd10c39] Error parsing json {:source=>"message", :raw=>" \"data\": [", :exception=>#<LogStash::Json::ParserError: Unexpected character (':' (code 58)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: (byte[])" "data": ["; line: 1, column: 12]>}
[2022-04-28T14:39:12,219][WARN ][logstash.filters.split ][main][3b78a77ee766469bb69c5822553d6a87e8c3bb48248d9f2a5fa111408c3d61eb] Only String and Array types are splittable. field:data is of type = NilClass
So, my gut feeling is that logstash doesnt like formatted jsons, and this is why i am having the error. But... why is it not doing anything with the one liner?
Have any of you tested this and having the same problem?
This is interesting... i changed the output to rubydebug and i have this
Looks like it is parsing (or at least trying) the message, but with a lot of errors. Also it is escaping my json fields ( \ is added to the double quote of the name field)
Now it is obvious, it is because you are using the file input plugin.
I you read the documentation of the file input plugin, it is print
By default, each event is assumed to be one line and a line is taken to be the text before a newline character. If you would like to join multiple log lines into one event, you’ll want to use the multiline codec.
So basically the json filter can't process correctly because the file input plugin split the input json when he is well formated in the source file.
So, has it is recommended by the documentation, you have to use the multiline codec to get the entire file content. So you config file need to look like this :
input {
file{
path => "/Users/javi/Downloads/logstash-8.1.3/mytest.json"
start_position => "beginning"
sincedb_path => ".sincedb"
codec => multiline { # each line not starting with "azertyqwerty" is merged with the previous one.
pattern => "^azertyqwerty"
negate => "true"
what => "previous"
}
}
}
filter {
json {
source => "message"
}
split {
field => "data"
}
}
output {
file {
path => "/Users/javi/Downloads/logstash-8.1.3/testmutated3.json"
}
}
it contains \ to show that the message field contains a string and this string also contains " special character
It doesnt process the file. I have noticed that sometimes if i add an extra blank line at the end or the beginning of the file, it processes it. Its quite weird
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.