I have a requirement where the file name (in the output) in a specific way.
After 11.30pm, It need to take next day date.
For example, today is 13th Oct 2020, the file name is ouput_13102020.log
but then once it passes 11.30pm then the output should be output_14102020.log
Because i need file data from 11.30.001 to next day 11.30.000
I could build file name in the ruby script and set a event.set('filename', value)
but i am wondering if there is a better way to do it.
Here is code snippet generating the logic:
require 'date'
time = Time.now
if time.hour == 4 && time.min > 30
time = DateTime.now.next_day(1).to_time
end
puts "logstash_output_"+time.strftime("%d%m%Y")