I have an input file where each line is a JSON object like the following:
{
"status_code" => "200",
"method" => "GET",
"country" => "US",
"field" => "something",
}
The goal is (for each JSON record) to extract all the fields values and write them in an output file as a single line:
"200" "GET" "US" "something" ----> object 1
"404" "GET" "IT" "something_2" -----> object 2
This is my conf:
input {
file {
path => "path/to/input.json"
codec => "json"
start_position => "beginning"
}
}
filter {
json {
source => "message"
}
mutate {
add_field => {
"status_code" => "%{[status_code]}"
"method" => "%{[method]}"
"country" => "%{[country]}"
"field" => "%{[field]}"
}
}
mutate {
remove_field => [ "message" ]
}
}
output {
file {
path => "path/to/output.txt"
codec => line { format => "%{[status_code]} %{[method]} %{[country]} %{[field]}" }
}
}
which results in
%{[status_code]} %{[method]} %{[country]} %{[field]}
Any suggestion about that?
Thanks