Hello,
I'm using a jms input to index data from queues, some fields contains
two values ("2018-07-12T23:30:00.000+0000" and
"2018-07-12T00:00:00.000+0000") that I have to replace with null value.
The input message look like this : [{"DATE1":"2018-07-13T10:00:00.000+0000","ID":"13","DATE_1":null,"REF":"REF0000056062","SUBSCRIPTION_SUBREF":"118259","REPORT":"INSTRUCTIONS"},{"DATE1":"2018-07-13T00:00:00.000+0000","ID":"13","DATE_1":null,"REF":"REF0000056062","SUBSCRIPTION_SUBREF":"118259","REPORT":"INSTRUCTIONS"},{"DATE1":"2018-07-13T23:00:00.000+0000","ID":"13","DATE_1":null,"REF":"REF0000056062","SUBSCRIPTION_SUBREF":"118259","REPORT":"INSTRUCTIONS"}]
My goal is to get this result:
[{"DATE1":"2018-07-13T10:00:00.000+0000","ID":"13","DATE_1":null,"REF":"REF0000056062","SUBSCRIPTION_SUBREF":"118259","REPORT":"INSTRUCTIONS"},{"DATE1":null,"ID":"13","DATE_1":null,"REF":"REF0000056062","SUBSCRIPTION_SUBREF":"118259","REPORT":"INSTRUCTIONS"},{"DATE1":null,"ID":"13","DATE_1":null,"REF":"REF0000056062","SUBSCRIPTION_SUBREF":"118259","REPORT":"INSTRUCTIONS"}]
I have tried this code but it remove completely the field from the JSON :
mutate {
add_field => {
"replace_date1" => "%{+YYYY-MM-dd}T23:30:00.000+0000"
"replace_date2" => "%{+YYYY-MM-dd}T00:00:00.000+0000"
}
}
if [DATE1] == [replace_date1] or [DATE1] == [replace_date2] {
ruby { code => 'event.set("DATE1", nil)' }
}
Result :
[{"DATE1":"2018-07-13T10:00:00.000+0000","ID":"13","DATE_1":null,"REF":"REF0000056062","SUBSCRIPTION_SUBREF":"118259","REPORT":"INSTRUCTIONS"},{"ID":"13","DATE_1":null,"REF":"REF0000056062","SUBSCRIPTION_SUBREF":"118259","REPORT":"INSTRUCTIONS"},{"ID":"13","DATE_1":null,"REF":"REF0000056062","SUBSCRIPTION_SUBREF":"118259","REPORT":"INSTRUCTIONS"}]
Thank you