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!

Updated Team Landing Page in Splunk Observability

We’re making some changes to the team landing page in Splunk Observability, based on your feedback. The ...

New! Splunk Observability Search Enhancements for Splunk APM Services/Traces and ...

Regardless of where you are in Splunk Observability, you can search for relevant APM targets including service ...

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...