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!

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...

Enterprise Security Content Update (ESCU) | New Releases

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

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...