Splunk Search

Explorer

Hello Community,

I have quite a strange issue to face...
For a project I'm working on, I would need to create a new case if the search returns no events.
I've tried to create a dummy example to make myself clear:

`| makeresults | eval letter1="A", letter2="B", letter3="C" | append     [| makeresults     | eval letter1="D", letter2="E", letter3="F"] | search letter1="K"| appendpipe     [| ??ifnotresults??     | append         [| makeresults         | eval letter1="X", letter2="Y", letter3="Z"]     | where false() ] | table letter1 letter2 letter3`

In particular, I have no idea how to evaluate the ??ifnotresults??  part.

Do you think it is possible to achieve this?

Labels (3)

• table

1 Solution
SplunkTrust

Test for results using stats count and where count=0 within the appendpipe.

``````| makeresults
| eval letter1="A", letter2="B", letter3="C"
| append
[| makeresults
| eval letter1="D", letter2="E", letter3="F"]
| search letter1="K"
| appendpipe
[ stats count
| eval letter1="X", letter2="Y", letter3="Z"
| where count=0
| fields - count ]
| table letter1 letter2 letter3``````

---
If this reply helps you, Karma would be appreciated.
SplunkTrust

Test for results using stats count and where count=0 within the appendpipe.

``````| makeresults
| eval letter1="A", letter2="B", letter3="C"
| append
[| makeresults
| eval letter1="D", letter2="E", letter3="F"]
| search letter1="K"
| appendpipe
[ stats count
| eval letter1="X", letter2="Y", letter3="Z"
| where count=0
| fields - count ]
| table letter1 letter2 letter3``````

---
If this reply helps you, Karma would be appreciated.
SplunkTrust

@Gian89,

let me understand:

• you have many events from e.g. a list of hosts and you want to have a message when there isn't any result e.g. from one of those hosts, is it correct?

If this is your situation, you have three choices:

• if you have only one check to perform (e.g. only one host),
• if you have few checks to perform (e.g. few hosts to check),
• if you have many ckecks to perform (e.g. many hosts to check).

in the first case you have to run a simple search and generate an alert if there isn't any result

``| makeresults index=_internal host=your_host``

in the second case, you have to run a simple search like this:

``````| metasearch index=_internal hostIN (host1, host2,host3)
| stats count BY host
| append [ | makeresults | eval host=host1, count=0 | fields host count ]
| append [ | makeresults | eval host=host2, count=0 | fields host count ]
| append [ | makeresults | eval host=host3, count=0 | fields host count ]
| stats sum(count) AS total BY host
| where total=0``````

In the third case, you have to creat e a lookup (called e.g. perimeter.csv) containing the list of objects to search (e.g. host) and run something like this:

``````| metasearch index=_internal hostIN (host1, host2,host3)
| eval host=lower(host)
| stats count BY host
| append [ | inputlookup perimeter.csv | eval host=lower(host), count=0 | fields host count ]
| stats sum(count) AS total BY host
| where total=0``````

Ciao.

Giuseppe

Explorer

Ciao Giuseppe,

thanks for your answer but it was not what I was looking for. The answer from richgalloway is what I was looking for 🙂

SplunkTrust

Hi @Gian89,

the most important thingi is that you solved your need.

We created an italian Splunk User Group, we didn't still have any event but we're organizing.

See next time.

Ciao and happy splunking.

Giuseppe

P.S.: Karma Points are appreciated by all the Contributors.

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 ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...