Splunk Search

extract date from string

sravanthikand
New Member

Hello

I have string from nessus . Wed Jun 6 02:02:10 2018 .

I need to extract the date . strftime and strptime returns NULL.

Any ideas for rex extraction ?

I need to compare and sort the date for the last 45 days .

Thanks

Tags (1)
0 Karma

woodcock
Esteemed Legend

Along with the answer from @mus, you need to make sure that you have a field myTime first. You create one like this:

| rex "(?<myTime>(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+\S+\d+\s+\d+:\d+:\d+\s+\d+)"

MuS
Legend

Hi sravanthikand,

try this strptime() format:

| makeresults 
| eval myTime="Wed Jun 6 02:02:10 2018" 
| eval epoch_time=strptime(myTime, "%c") 
| eval _time=epoch_time

This will create a valid epoch timestamp.

alt text

Hope this helps ...

cheers, MuS

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 ...