hi am newbie
I have a duration time value with the format "1d hh:mm:ss"
but I haven't gotten a thread that discusses summing with that format.
Example:
hostname=hostA outage="1d 21:49:48"
hostname=hostA outage="10:30:50"
i want the result can be like that > total outage = 2d 08:20:38 or 56:20:38
happy for the help
thanks
You should convert your outage strings to seconds, sum them, then convert them back to durations
| rex field=outage "((((?<days>\d+)d )?(?<hours>\d+):)?(?<mins>\d+):)?(?<secs>\d+)"
| fillnull value=0 days hours mins secs
| eval outage_seconds=(((((days * 24) + hours) * 60) + mins) * 60) + secs
| stats sum(outage_seconds) as total_outage
| eval outage_total=replace(tostring(total_outage,"duration"), "\+", "d ")
You should convert your outage strings to seconds, sum them, then convert them back to durations
| rex field=outage "((((?<days>\d+)d )?(?<hours>\d+):)?(?<mins>\d+):)?(?<secs>\d+)"
| fillnull value=0 days hours mins secs
| eval outage_seconds=(((((days * 24) + hours) * 60) + mins) * 60) + secs
| stats sum(outage_seconds) as total_outage
| eval outage_total=replace(tostring(total_outage,"duration"), "\+", "d ")
Big Thanks ITWhisperer
its work for me, i must learn rex specialy 😅
btw sorry my translate english 😁