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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...