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?
Thanks in advance for your kind support
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
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
i @Gian89,
let me understand:
If this is your situation, you have three choices:
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
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 🙂
Thanks anyway for your feedback!
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.