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!

Splunk Observability Cloud | Customer Survey!

If you use Splunk Observability Cloud, we invite you to share your valuable insights with us through a brief ...

Happy CX Day, Splunk Community!

Happy CX Day, Splunk Community! CX stands for Customer Experience, and today, October 3rd, is CX Day — a ...

.conf23 | Get Your Cybersecurity Defense Analyst Certification in Vegas

We’re excited to announce a new Splunk certification exam being released at .conf23! If you’re going to Las ...