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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...