Hello,
I'm trying to extract fields from my JSON file, but I have _jsonparsefailure" error, I tried many other filters like grok Split or vk but always the same results, logstash doesn't extract the values of the fields separately.
Here is my Piepline.conf
input {
file {
type => "json"
path => "/var/lib/logstash/test1.json"
start_position => "beginning"
sincedb_path => "/dev/null"
# codec => json {}
}
}
filter {
json {
source => "message"
target => "event"
}
mutate {
gsub => ["message","\]",""]
gsub => ["message","\[",""]
}
}
output {
elasticsearch {
hosts => "http://localhost:9200"
index => "my_index"
document_type => "json"
ecs_compatibility => disabled
}
stdout{}
}
this is my JSON File :
[{ "start" : 1619731540, "end" : 1619731550, "scen_id" : 0, "conn_id" : 2, "test_id" : 1, "direction" : "fw", "srcip" : "0.0.0.0", "dstip" : "0.0.0.0", "state" : "Atomic Delay", "samples" : 1, "mean_latency" : 261131, "mean_jitter" : 99494, "lost_pkts" : 0, "sent_pkts" : 100, "recv_pkts" : 100}
,{ "start" : 1619731540, "end" : 1619731550, "scen_id" : 0, "conn_id" : 2, "test_id" : 1, "direction" : "sw", "srcip" : "0.0.0.0", "dstip" : "0.0.0.0", "state" : "Atomic Delay", "samples" : 1, "mean_latency" : 218259, "mean_jitter" : 21353, "lost_pkts" : 0, "sent_pkts" : 100, "recv_pkts" : 100}
]
And this is how the stdout shows the result :
//{
"path" => "/var/lib/logstash/Twamp_Results/754002845-Twamp_vProbe-0-1619731550-pathanomaly.json",
"@timestamp" => 2021-06-01T09:09:53.436Z,
"host" => "localhost.localdomain",
"tags" => [
[0] "_jsonparsefailure"
],
"message" => "{ \"start\" : 1619731540, \"end\" : 1619731550, \"scen_id\" : 0, \"conn_id\" : 2, \"test_id\" : 1, \"direction\" : \"fw\", \"srcip\" : \"10.1.254.83\", \"dstip\" : \"10.1.158.113\", \"state\" : \"Atomic Delay\", \"samples\" : 1, \"mean_latency\" : 261131, \"mean_jitter\" : 99494, \"lost_pkts\" : 0, \"sent_pkts\" : 100, \"recv_pkts\" : 100}",
"type" => "json",
"@version" => "1"
}
{
"path" => "/var/lib/logstash/Twamp_Results/754002845-Twamp_vProbe-0-1619731550-pathanomaly.json",
"@timestamp" => 2021-06-01T09:09:53.477Z,
"host" => "localhost.localdomain",
"tags" => [
[0] "_jsonparsefailure"
],
"message" => ",{ \"start\" : 1619731540, \"end\" : 1619731550, \"scen_id\" : 0, \"conn_id\" : 2, \"test_id\" : 1, \"direction\" : \"sw\", \"srcip\" : \"10.1.158.113\", \"dstip\" : \"10.1.254.83\", \"state\" : \"Atomic Delay\", \"samples\" : 1, \"mean_latency\" : 218259, \"mean_jitter\" : 21353, \"lost_pkts\" : 0, \"sent_pkts\" : 100, \"recv_pkts\" : 100}",
"type" => "json",
"@version" => "1"
}
{
"path" => "/var/lib/logstash/Twamp_Results/754002845-Twamp_vProbe-0-1619731550-pathanomaly.json",
"@timestamp" => 2021-06-01T09:09:53.481Z,
"host" => "localhost.localdomain",
"tags" => [
[0] "_jsonparsefailure"
],
"message" => "",
"type" => "json",
"@version" => "1"
}
Could someone help me with that, please?
Thank you in advance