Splunk Search

How to handle "no results found" in subsearch

tsa_asap
Engager

Hi all,

I have a subsearch that returns me the delta between two events. The problem is, sometimes the two events I´m looking for don´t exist. This results in the following Error in 'eval' command: The expression is malformed. An unexpected character is reached at ')'.

The subsearch looks like this:

| eval DisruptionInSeconds = [ my subsearch that returns the delta between two events 
| sort - _time 
| stats sum(timeDeltaS) as search | eval search ="\"".search."\"" ]

If these two events don´t exist, the search should return 0 (not NULL). How do I do that?

Thanks in advance for your help.

0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Use appendpipe.

| eval DisruptionInSeconds = [ my subsearch that returns the delta between two events 
| sort - _time 
| stats sum(timeDeltaS) as search | eval search ="\"".search."\"" 
| appendpipe [ stats count | eval search="0" | where count==0 | fields - count ] ]
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Use appendpipe.

| eval DisruptionInSeconds = [ my subsearch that returns the delta between two events 
| sort - _time 
| stats sum(timeDeltaS) as search | eval search ="\"".search."\"" 
| appendpipe [ stats count | eval search="0" | where count==0 | fields - count ] ]
---
If this reply helps you, Karma would be appreciated.

tsa_asap
Engager

That works. Thanks!

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...