I have logfile containing log in this form
"{\"user_id\":\"79\",\"timestamp\":\"2016-12-28T11:10:26Z\",\"operation\":\"ver3 - Requested for recommended,verified handle information\",\"data\":\"\",\"content_id\":\"\",\"channel_id\":\"\"}"
for which I have written logstash configuration
input {
beats {
port => "5043"
}
}
filter{
grok {
match => { "message" => "%{QS:mydata}"}
}
json {
source => "message"
target => "parsedJson"
}
mutate {
add_field =>{
"user_id" => "%{[parsedJson.user_id]}"
"operation" => "%{[parsedJson][operation]}"
"data"=> "%{[parsedJson][operation]}"
}
}
}
output {
elasticsearch {
hosts => [ "localhost:9200" ]
}
}
basically I have tried many permutations to fetch the value but in elasticsearch data is like the image below. I am not able to fetch data from JSON and assign to a new value. please help.
What if you try including the
add_field
within yourjson
filter and makemydata
as yoursource
injson
. Also please make sure that you don't separate theadd_field
value with the.
dot:Hope it helps!