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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...