Hi,
I am trying to add day(s) to a date in logstash, based on a filebeat prospector configuration, but when I try adding, I get an error like this:
[2019-03-31T16:43:14,624][ERROR][logstash.filters.ruby ] Ruby exception occurred: no implicit conversion of Fixnum into String
Here is the code:
mutate { add_field => { "[@metadata][record_date]" => "%{@timestamp}" } }
date {
match => [ "[@metadata][record_date]", "YYYY-MM-dd HH:mm:ss,SSS" ]
target => "[@metadata][record_date]"
}
mutate { add_tag => ["debug_tag_before_inside_if_pruning_frequency_12"] }
mutate { add_field => { "[@metadata][date_format]" => "%Y.%m.%d" } }
# Set expiration date based on the provided retention value (if not provided, assume the default value)
ruby {
code => "
event.set('[@metadata][expiry_index]', (event.get('[@metadata][record_date]') + (86400 * (event.get('retention')))).strftime(event.get('[@metadata][date_format]')));
"
}
I broke down the ruby code, and the error happens when trying to add the 86400 * the number of days to the date. Here are the values for the fields:
"@metadata" => {
"record_date" => "2019-03-31T20:43:07.227Z",
"date_format" => "%Y.%m.%d",
},
"retention" => 15
Any help will be very appreciated.
Thanks,
Rob