I am creating an application where I need to retrieve key value pairs from json object in logs with the help of logstash configuraition.
Here is my configuration:
input{
file{
path => "D:\ELK_Info\TestLogs_Updated_tablev4.log"
start_position => beginning
codec => multiline {
pattern => "^%{TIMESTAMP_ISO8601}"
negate => true
what => "previous"
}
}
}
filter{
grok{
match => {
"message" => "%{IP:client_ip}%{NOTSPACE:space}%{GREEDYDATA:json_data}"
}
}
#mutate { remove_field => [ "tags"]}
json { source => "json_data" target => "parsedJson" remove_field=>["json_data"]}
mutate {
add_field => {
"AssetManagerId" => "%{[parsedJson][AssetManagerId]}"
"Amount" => "%{[parsedJson][Amount]}"
"AccountId" => "%{[parsedJson][AccountId]}"
"RequestCode" => "%{[parsedJson][RequestCode]}"
"TicketNumber" => "%{[parsedJson][TicketNumber]}"
"Status" => "%{[parsedJson][Status]}"
"message" => ["%{[parsedJson][message]}"]
}
}
}
output {
file{
path => "D:\ELK_Info\logstashOutput.log"
}
}
Here is the log for example:
Sep 28 15:09:50 52.231.153.246 gateway: [6] INFO AppLog - 180 - XXXGatewayAPI.APIHandlers - UpdateDepositTicket called by xyzadmin from 211.211.211.211: {"AssetManagerId":211,"AccountId":211,"AssetId":211,"AssetName":" ","Amount":"211","RequestCode":"211-211-211-211-211","RequestIP":"211.211.211.211","RequestUser":211,"RequestUserName":"211@211.com","OperatorId":211,"Status":"Accepted","FeeAmt":0,"UpdatedByUser":211,"UpdatedByUserName":"211","TicketNumber":211,"DepositInfo":"{"Full Name":"211","language":"kr","Comments":""}","CreatedTimestamp":"2018-09-27T11:02:22Z","LastUpdateTimeStamp":"211-09-211:09:48.203Z","Comments":,"Attachments":null,"type":"deposit"}
With my current configuration, I get key value pair as:
"Status" : "%{[parsedJson][Status]}"
whereas, I need exact value for key 'Status' in json in the place of "%{[parsedJson][Status]}".
What changes I need to make to have required output?