Splunk Search

How to specific time range in my search results

AL3Z
Builder

Hi all,

How to give the range to that first and last if the date is in between last 3weeks till today which matches to first or last in the below splunk query.

| eval first = strptime(first_detected, "%Y-%m-%dT%H:%M:%S.%3N%Z"),
last= strptime(last_detected, "%Y-%m-%dT%H:%M:%S.%3N%Z")

Thanks..

Labels (1)
0 Karma

AL3Z
Builder

@richgalloway @gcusello 

Here my search should calculate what is there in between if the first matches to that or last matches to particular range from last 3 weeks to till todaysdate..

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @AL3Z ,

using my search you have the earliest and the latest timestamp in your results, then you can add all the information you need in the stats command.

Ciao.

Giuseppe

richgalloway
SplunkTrust
SplunkTrust

Please tell us more about your use case.  What are the desired results?

---
If this reply helps you, Karma would be appreciated.
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @AL3Z ,

please try something like this:

<your_search>
| stats earliest(_time) AS earliest latest(_time) AS latest
| eval earliest=strftime(earliest, "%Y-%m-%dT%H:%M:%S.%3N%Z"),
latest=strptime(latest, "%Y-%m-%dT%H:%M:%S.%3N%Z")

Ciao.

Giuseppe

Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

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