Logstash is dropping fields which has "nil" values, but I don't want those fields to be drop, but at least we can set it to default values if the field is nil, else it has it's original value.
I tried with this code found on the discussion form, but couldn't work.
Logstash Config
ruby {
code => "
hash = event.to_hash
hash.each do |k,v|
if v == nil
event[k] = 0
end
end
"
}
Logstash OUTPUT
"response" => {
"body" => {
"entries" => {
"values" => {
"ChangeRequestStatusString" => "11",
"ConditionDisplay1" => nil,
"ConditionDisplay2" => nil,
"ConditionDisplay3" => nil,
"SLA Breach Exception" => nil,
"ConditionDisplay4" => nil,
"ConditionDisplay5" => nil,
"Middle Initial" => "B",
"UC Res Result Seconds" => 0,
"AllCIsInTab" => "Yes",
"Show For Process_Assignee" => nil,
"Infrastructure Change ID" => "CRQ000000600000",
"Site ID" => nil,
"Release_ID" => nil,
"Active Tasks" => nil,
"BTSEnd Time" => nil,
"Permission" => "Infrastructure Master",
"SFA_Date" => "2022-05-10T15:02:02.000+0000",
"Performance Rating" => 3,
"InstanceId" => "IDGAA5V0frw3re3eSQQMWS",
"UC Acknowledgment End Date" => nil,
"Override Group" => nil,
"AllowNext" => nil,
"Actual End Date" => "2022-05-14T02:30:00.000+0000",
"zTmpRSSOAuthentication" => nil,
"Support Organization2" => "User Service Desk",
"Show For Process" => nil,
"FindApproversOn" => nil,
"Active Approval" => nil,
"OLA Res Target Seconds" => 0,
"Return Code_Manager" => nil,
"SRInstanceID" => nil,
"Requested End Date" => nil,
"View Accessible" => nil,
"zTmpIntAutoStartTime" => nil,
"OLA Res Business Hour Seconds2" => 0,
"StartStop_EffortLogId" => nil,
"zTmpCheckCHGDPN" => nil,
"SLA Resp Target Duration" => nil,
"NewBroadcastCount" => nil,
"ChgImpGrp" => nil,
"AllowApproval" => nil,
"Corporate ID" => "4333333",
"StartStop_Assignee" => nil,
"Work Log" => nil,
"z2AF_Work Log01" => nil,
"z2AF_Work Log02" => nil,
"zD_TADOccurred" => nil,
"z2AF_Work Log03" => nil,
Please help ,
Thank You