Splunk Search

Need help with python script to log into Splunk Cloud

NanSplk01
Communicator

I have the following script, but it keeps erroring out.

def connect_to_splunk(username,password,host='http://xxxxxxxx.splunkcloud.com',port='8089',owner='admin',app='search',sharing='user'😞
    try:
        service=client.connect(username=username,password=password,host=host,port=port,owner=owner,app='search',sharing=sharing)
        if splunk_service:
            print("Splunk login successful")
            print("......................" )
    except Exception as e:
        print(e)

def main():
    try:
        splunk_service = connect_to_splunk(username='xxxxxx',password='xxxxxxx')
    except Exception as e:
        print(e)  
 
There is no error from the debugger (Using Visual Studio).  Would appreciate any assistance.
Tags (2)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

What is the error?

---
If this reply helps you, Karma would be appreciated.
0 Karma

NanSplk01
Communicator

Unfortunately it doesn't give me one.  So I'm not positive what's going on.

Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

We don't know what's going on, either.  What makes you think it's "erroring out" if there are no errors?

You may have to add some debugging code to the script so it tells you more about what is happening.

---
If this reply helps you, Karma would be appreciated.
0 Karma

NanSplk01
Communicator

I will test it again later today and let you know if I then see an error.  I know the library I wanted to bring in splunklib did not exist.

0 Karma
Get Updates on the Splunk Community!

AppDynamics Summer Webinars

This summer, our mighty AppDynamics team is cooking up some delicious content on YouTube Live to satiate your ...

SOCin’ it to you at Splunk University

Splunk University is expanding its instructor-led learning portfolio with dedicated Security tracks at .conf25 ...

Credit Card Data Protection & PCI Compliance with Splunk Edge Processor

Organizations handling credit card transactions know that PCI DSS compliance is both critical and complex. The ...