Archive

Alert only if value exists

Path Finder

Hello Splunkers,

We have a search that runs every 30 minutes, and then sends and email. The problem is that there may not be a value in the results. The search looks for a "deny" event. We would like the search to run every 30 minutes, but ONLY send an email alert IF there are values in the results; in other words only if there is a deny event.

index=xncsyslog | search action="deny" | dedup deviceid | fields _time action group user deviceid devicetype agent ip | table _time user deviceid devicetype action group agent ip

Tags (1)
0 Karma
1 Solution

Legend

Do you need this? It would run every 30 min for last 30 minutes and will trigger only if the table has record/s for deny event based on deviceid:

index=xncsyslog action="deny" earliest=-30m latest=now
|dedup deviceid 
|table _time user deviceid devicetype action group agent ip

Under alerts Trigger Conditions set to trigger when Number of Results > 0

Set on every 30 minutes cron schedule : */30 * * * *

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

Path Finder

Thank you. I've made this change to both the code and the trigger conditions. The next report runs in about 10 minutes. We'll see if this works.

0 Karma

Path Finder

Thank you. However, we do not know which devices will attempt to connect. These are all BYO devices connecting. We have two portals. One portal is permitted for all devices, while the other portal is approved only for select devices.

0 Karma

Legend

Do you need this? It would run every 30 min for last 30 minutes and will trigger only if the table has record/s for deny event based on deviceid:

index=xncsyslog action="deny" earliest=-30m latest=now
|dedup deviceid 
|table _time user deviceid devicetype action group agent ip

Under alerts Trigger Conditions set to trigger when Number of Results > 0

Set on every 30 minutes cron schedule : */30 * * * *

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

SplunkTrust
SplunkTrust

Hi jaxjohnny,
to do what you want, you have to create a lookup with all your deviceid to monitor (calling it e.g. Perimeter.csv) in which there is a column called "deviceid" (and eventually other columns describing each device) and then run a search like this:

index=xncsyslog action="deny" 
| eval deviceid=upper(deviceid) 
| stats count by deviceid 
| append [ | inputlookup Perimeter.csv | eval count=0 | fields deviceid count ] 
| stats sum(count) AS Total by deviceid 

In this way, missed deviceids have Total=0, the other have Total>0.

(Note that if you insert the search condition action="deny" after a | and a search command, your search is slower! and that you don't need to use the field command before table command).

You can insert at the end of your search | where Total=0 and create an alert or create a dashboard that shows the status of your devices.

You could also show status of your devices inserting at the end of your search | rangemap field=Somma severe=0-0 low=1-1000000000 default=severe

If you like to show status of your devices in a graphic mode, follow the example in Splunk 6.x Dashboard Examples App (https://splunkbase.splunk.com/app/1603/).

Bye.
Giuseppe

0 Karma

SplunkTrust
SplunkTrust

Hi jaxjohnny,
to do what you want, you have to create a lookup with all your deviceid to monitor (calling it e.g. Perimeter.csv) in which there is a column called "deviceid" (and eventually other columns describing each device) and then run a search like this:

index=xncsyslog action="deny" 
| eval deviceid=upper(deviceid) 
| stats count by deviceid 
| append [ | inputlookup Perimeter.csv | eval count=0 | fields deviceid count ] 
| stats sum(count) AS Total by deviceid 

In this way, missed deviceids have Total=0, the other have Total>0.

(Note that if you insert the search condition action="deny" after a | and a search command, your search is slower! and that you don't need to use the field command before table command).

You can insert at the end of your search | where Total=0 and create an alert or create a dashboard that shows the status of your devices.

You could also show status of your devices inserting at the end of your search | rangemap field=Somma severe=0-0 low=1-1000000000 default=severe

If you like to show status of your devices in a graphic mode, follow the example in Splunk 6.x Dashboard Examples App (https://splunkbase.splunk.com/app/1603/).

Bye.
Giuseppe

0 Karma

Legend

Do you need this

index=xncsyslog action="deny" 
|dedup deviceid 
|table _time user deviceid devicetype action group agent ip

Under alerts Trigger Conditions set to trigger when Number of Results > 0

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!