Convert time field type string to integer

I have a data type string format "22h30m15s"
I would like to convert this data to type integer = 81,015 second

You could solve that with a little bit of Ruby:

ruby {
  code => "
    s = event.get('your_field')
    vals = s.match /(\d+)h(\d+)m(\d+)s/
    if vals then
      seconds = vals[1].to_i*3600+vals[2].to_i*60+vals[3].to_i
      event.set('your_int_field', seconds)
    end
  "
}

Hi, Jenni

Thank you for you recommend.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.