Getting Data In

Processing events with an external script

wibay
New Member

I'd like to take various actions against real-time events from Splunk. What's considering the best practice for this? I'm not sure if it would be preferred to run a real-time search in Splunk and kick off a scripted alert for those events that I want to process further (running zcat on the $8 argument to the script to get at the events), or if it's better to run a "splunk rtsearch" from the CLI. Any pointers on how to really iterate through the rtsearch results, similar to something like this:

splunk rtsearch "link down | table _time, host" -preview false -header false | while read time host; do
  something
done
Tags (1)
0 Karma

woodcock
Esteemed Legend

I would advise against actual real-time searches and use near-real-time scheduled searches instead. Unless you have designed/scaled your infrastructure explicitly for rtsearch, you will become a very disliked person because each rtsearch permanently consumes 1 core on each Splunk server. Using rtsearch also has the problem that the smaller window you use, the more events you will never see due to various pipeline latencies (e.g. if the event does not arrive in Splunk until 2 minutes after it happened and you have a 1-minute window, you will never see the event). What you really need to do is schedule a search on a duty cycle that is longer than your biggest average delivery latency. So something like every 5 minutes for the last 5 minutes. In the schedule options, you can set a script to call when the results set has more than 1 event. Now all you need to do is write the script and put it on your search head.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...