Splunk Search

How to compare CutoffTime with current time?

pradeepkm
Explorer

 I have created a lookup table with filename and cutofftime within which we have to receive the file. I have to compare Cutofftime to check if its falling within 30 mins of current time and retrieve that particular file name from lookup  and search for it. Please help me with query

Labels (4)
Tags (1)
0 Karma

somesoni2
Revered Legend

Assuming your lookup field for cutofftime has epoch value, you can retrieve the filename based on your condition like this:

| inputlookup yourLookupName.csv | table filename cutofftime | where abs(cutofftime-now())<=1800 | table filename

If it's in some specific string timestamp format, replace "abs(cutofftime-now())" with "abs(strptime(cutofftime,"Your Time Format")-now()".  Find your Timeformat here.

Once you finalize your above query, your search data for your retrieved file like this:

index=YourIndex sourcetype=YourSourcetype [| your finalized query | which will give filename. your may have to rename field 'filename' to field name that your index/sourcetype has] 

pradeepkm
Explorer

I was able to figure out working query.Yes I have used similar logic mentioned by you.Thanks for the response.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Tech Talk Recap | Mastering Threat Hunting

Mastering Threat HuntingDive into the world of threat hunting, exploring the key differences between ...

Observability for AI Applications: Troubleshooting Latency

If you’re working with proprietary company data, you’re probably going to have a locally hosted LLM or many ...

Splunk AI Assistant for SPL vs. ChatGPT: Which One is Better?

In the age of AI, every tool promises to make our lives easier. From summarizing content to writing code, ...