Hi Experts,
I want to ingest data from a text file (refer data.txt) to elastic using logstash and in order to achieve it, I have created the logstash.conf file as mentioned below -
logstash.conf -
input {
file {
path => "/temp/data.txt"
start_position => "beginning"
sincedb_path => "/dev/null"
codec => multiline {
pattern => "^Spalanzani"
negate => true
what => previous
auto_flush_interval => 1
multiline_tag => ""
}
}
}
filter { json { source => "message" target => "eventData" remove_field => [ "message" ] } }
output {
stdout { }
}
data.txt -
[
{
"id": "id",
"name": "name",
"Severity": "severity",
"start_time": "start_time",
"updated_time": "updated_time",
"end_time": "end_time",
"groupname": "groupname"
},
{
"id": "1",
"name": "test1",
"Severity": "P1",
"start_time": "60",
"updated_time": "60",
"end_time": "120",
"groupname": "test_G"
},
{
"id": "2",
"name": "test2",
"Severity": "P1",
"start_time": "60",
"updated_time": "60",
"end_time": "120",
"groupname": "test_P"
}
]
However, when I test the logstash conf file, it gives an parse error -
[WARN ] 2023-06-02 10:41:04.098 [[main]>worker0] json - Error parsing json {:source=>"message", :raw=>"[\n {\n \"id\": \"id\",\n \"name\": \"name\",\n...:exception=>#<LogStash::Json::ParserError: Unexpected end-of-input: expected close marker for Array (start marker at [Source: (byte[])"[
Could you please guide me to parse the text file.
Thanks in advance,
Nivedita