Splunk Search

Uptime Conversion

cinsley
Explorer

Below is a two result conversion table.  The data I am given, some will have days in the field and others will only have time.  How do I setup a conversion to handle this situation.  The convert auto(UpTime) works great as long as the field contains an entry with days.  The rex works well, again as long as the field contains a string containing days.

| makeresults
| eval UpTime="5:10:07:03.2419156"|append [|makeresults |eval UpTime="9:28:35.1006819"]
| convert auto(UpTime) AS autoDays
| rex field=UpTime "(?<days>\d+):(?<hours>\d+):(?<minutes>\d+):(?<seconds>\d+)\.(?<micro>\d+)"
| table UpTime, autoDays, days,hours,minutes, seconds, micro

Results:

UpTime                            autoDays  days    hours   minutes seconds              micro 

5:10:07:03.2419156                5           5         10             07            03          2419156
9:28:35.1006819                      9

Labels (1)
Tags (1)
0 Karma
1 Solution

kamlesh_vaghela
SplunkTrust
SplunkTrust

@cinsley 

Can you please try this?

| makeresults
| eval UpTime="5:10:07:03.2419156"|append [|makeresults |eval UpTime="9:28:35.1006819"]
| convert auto(UpTime) AS autoDays
| rex field=UpTime "((?<days>\d+):)?(?<hours>\d+):(?<minutes>\d+):(?<seconds>\d+)\.(?<micro>\d+)"
| table UpTime, autoDays, days,hours,minutes, seconds, micro

 

Thanks
KV
▄︻̷̿┻̿═━一

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

View solution in original post

cinsley
Explorer

That was the solution.   Thanks

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust
Glad to help you

Happy Splunking
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@cinsley 

Can you please try this?

| makeresults
| eval UpTime="5:10:07:03.2419156"|append [|makeresults |eval UpTime="9:28:35.1006819"]
| convert auto(UpTime) AS autoDays
| rex field=UpTime "((?<days>\d+):)?(?<hours>\d+):(?<minutes>\d+):(?<seconds>\d+)\.(?<micro>\d+)"
| table UpTime, autoDays, days,hours,minutes, seconds, micro

 

Thanks
KV
▄︻̷̿┻̿═━一

If any of my reply helps you to solve the problem Or gain knowledge, an upvote would be appreciated.

Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...