Can not parse bash output as json

I use shall script to generate dataset but logstash won't accept my message




Thanks for feature help.

The below works. Adding quotes around the field names.

input {
  generator {
    lines => [
     '{"results": [{ "id": "ICR=1549", "date": "2020-08-14" }]}'
    ]
    count => 1
    codec => "json"
  }
}
filter {
}
output {
  stdout { codec =>  "rubydebug" }
}

The below is what it appears like your data is formatted and gives a _jsonparsefailure

input {
  generator {
    lines => [
     '{results: [{ id: "ICR=1549", date: "2020-08-14" }]}'
    ]
    count => 1
    codec => "json"
  }
}
filter {
}
output {
  stdout { codec =>  "rubydebug" }
}

Add sine double quotes in your shell script and test.

So if bash outPut (") instead (") it is not a problem .

problem was last comma which corrupted whole json string.

I was suggesting editing your shell script to be something like

results="\"id\":\"${id}\",\"date\":\"${time}\"},${results}"

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.