Alerting

Alert triggered script produces different results from a CLI triggered script

jphilput1
Explorer

I have several scheduled alerts set to trigger a script on every run. The scripts run CLI searches, and dump the output into our ticketing system.

The scripts are triggering as expected, but the results from the alert triggered scripts are coming back with no data. However, when I trigger the same script manually for the same time frame, I get the results I expect.

In the most recent test, I set the alert to trigger within a less than a minute of me running the script from the CLI. The window was set to 24 hours, and the alert triggered version produced a 0 byte file, and the CLI triggered version produced a 40kb file.

Does anyone know why these differences might be showing up?

The permissions are the same, I'm running the script from the CLI as the splunk user, and I'm using the same script in both the alert and the CLI.

0 Karma
1 Solution

jphilput1
Explorer

I figured it out. Running from the CLI with the splunk user, the CLI search picks up the auth token in .splunk for that user. When the script is triggered by an alert, the auth token isn't checked.

I created a limited user with access to run the search I needed and added an -auth 'user:pass' to the script. That seems to solve the problem.

View solution in original post

0 Karma

jphilput1
Explorer

I figured it out. Running from the CLI with the splunk user, the CLI search picks up the auth token in .splunk for that user. When the script is triggered by an alert, the auth token isn't checked.

I created a limited user with access to run the search I needed and added an -auth 'user:pass' to the script. That seems to solve the problem.

0 Karma
Get Updates on the Splunk Community!

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

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

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...