Splunk Search

Filter events based on date that is currently a string?

craigbar
New Member

I am trying to filter results based on relative date (last 6 months). Splunk extracted the field I would like to use as a string. Here is an example: Computer Last Seen = "Mon Jun 01 20:26:49 EDT 2015". I have been attempting to use eval strptime to get create a field while searching. It is not working.

Can anyone suggest a better approach?
Thanks.

Tags (2)
0 Karma

woodcock
Esteemed Legend

Assuming the field that Splunk extracted is called Computer_Last_Seen, try this (15552000=6 months in seconds):

... | lastSeenTimeEpoch = strptime(Computer_Last_Seen, "%a %b %d %H:%M:%S %Z %Y") | eval AgeSeconds = now() - lastSeenTimeEpoch | where AgeSeconds < 15552000
0 Karma
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...