Alerting

Get auth token in alert script

Leo
Splunk Employee
Splunk Employee

Is it possible to get an auth token/session key in a python script triggered by an alert?

Tags (3)
0 Karma
1 Solution

starcher
Influencer

It work the same as it does for scheduled or modular inputs. I have actual walk through and link to already made code in my git repo. http://www.georgestarcher.com/2014/02/16/splunk-alert-scripts-automating-control/

View solution in original post

starcher
Influencer

It work the same as it does for scheduled or modular inputs. I have actual walk through and link to already made code in my git repo. http://www.georgestarcher.com/2014/02/16/splunk-alert-scripts-automating-control/

Leo
Splunk Employee
Splunk Employee

yeah, it does indeed. I messed up by calling Intersplunk.getOrganizedResults() before reading from the stdin. And now I see that Intersplunk actually reads from stdin itself.

0 Karma

starcher
Influencer

There was nothing special required for it to work and it does pass on stdio by design of Splunk. I have it working without issue on both Splunk v5 and Splunk v6. Is the hash bang at the the top of your alert script set to the correct path for your installation?

0 Karma

Leo
Splunk Employee
Splunk Employee

thanks, but looking at your alert_to_gsheet.py file, it seems like the session key is expected to be sent via stdin, which doesn't happen in my case. Do you have any special config that enables passing it? I tried setting 'passauth=true' in commands.conf, trying to trick it as if it was a search command and it still doesn't work: reading sys.stdin.readline() comes back empty...

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

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