Splunk Search

combining two searches

DTERM
Contributor

How can I combine the following two queries into a single search?

index=sendmail earliest="@d-2h" latest="@d+10h"
index=sendmail earliest="@d+10h" latest="@d-2h"

I've tried using pipes (|) and the AND operator with no luck.

Tags (1)
1 Solution

dwaddle
SplunkTrust
SplunkTrust

I have to agree with joelshprentz that your timeranges are somewhat unclear. But, if you cannot work out any other way of beating this, the append search command might work for you.

index=sendmail earliest="@d-2h" latest="@d+10h" | 
append [ search index=sendmail earliest="@d+10h" latest="@d-2h" ]

Append does, however some with some caveats. See http://www.splunk.com/base/Documentation/latest/SearchReference/Append for some details on it.

View solution in original post

dwaddle
SplunkTrust
SplunkTrust

I have to agree with joelshprentz that your timeranges are somewhat unclear. But, if you cannot work out any other way of beating this, the append search command might work for you.

index=sendmail earliest="@d-2h" latest="@d+10h" | 
append [ search index=sendmail earliest="@d+10h" latest="@d-2h" ]

Append does, however some with some caveats. See http://www.splunk.com/base/Documentation/latest/SearchReference/Append for some details on it.

joelshprentz
Path Finder

Could you explain the intent of the time ranges?

The first time range, earliest="@d-2h" latest="@d+10h", will select events with 10 PM last night < time < 10 AM this morning.

The second time range, earliest="@d+10h" latest="@d-2h", will select events with 10 AM this morning < time < 10 PM last night. No events will match the second time range.

See an explanation of the time range format at http://www.splunk.com/base/Documentation/latest/User/ChangeTheTimeRangeOfYourSearch

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