Getting Data In

How do I include leading 0 in the time fields

digital_alchemy
Path Finder

I would like to combine the date_hour, date_minute and date_second fields to display in the following format when using the top command: hh:mm:ss

The problem I'm having is that the output will remove any leading zeros from the minutes; so, for example instead of 12:05:02 I get 12:5:2.

This how I'm currently combining the fields:

mysearch | eval time = date_hour.":".date_minute.":".date_second | top time,src,src_port,dest,dest_port
0 Karma
1 Solution

bmacias84
Champion

The best way if possible is to convert or use epoch time with in your search. Then use strftime eval funtion to convert to the desired format.


eval time = strftime(epoch,%H:%M:%S)

additional reading:

Hope this help or gets you started. Dont forget to vote and accept answer that help.

Cheers

View solution in original post

bmacias84
Champion

The best way if possible is to convert or use epoch time with in your search. Then use strftime eval funtion to convert to the desired format.


eval time = strftime(epoch,%H:%M:%S)

additional reading:

Hope this help or gets you started. Dont forget to vote and accept answer that help.

Cheers

Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...