How about this?
* | head 1
| eval str="3 days 5 hrs 40 min 11 sec"
| eval duration_in_seconds=tonumber(replace(str, ".*?(\d+) sec", "\1"))
+ 60 * coalesce(tonumber(replace(str, ".*?(\d+) min.*", "\1")), 0)
+ 3600 * coalesce(tonumber(replace(str, ".*?(\d+) hrs.*", "\1")),0)
+ 86400 * coalesce(tonumber(replace(str, ".*?(\d+) days.*", "\1")),0)
| table str,duration_in_seconds
The eval duration_... could be used in the definition of a calculated field.
EDIT:
The solution above may not be optimal with regard to performance, because the string has to be parsed four times.
The idea behind this was to do it in a single eval expression.
If you don't mind to create additional fields, it may be better to do it in two steps:
1st step: field extraction:
... | rex field=str "^((?<days>\d+) days )?((?<hours>\d+) hrs )?((?<minutes>\d+) min )?(?<seconds>\d+) sec"
2nd step: field calculation:
... | eval duration_in_second=if(isnull(days),0,86400*days)
+ if(isnull(hours),0,3600*hours)
+ if(isnull(minutes),0,60*minutes)
+ seconds
... View more