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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...