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!

Full-Stack Security in Financial Services: AppDynamics, Cisco Secure Application, and ...

Full-Stack Security in Financial Services: AppDynamics, Cisco Secure Application, and Splunk ES Protecting a ...

It's Customer Success Time at .conf25

Hello Splunkers,   Ready for .conf25? The customer success and experience team is and can’t wait to see you ...

Pro Tips for First-Time .conf Attendees: Advice from SplunkTrust

Heading to your first .Conf? You’re in for an unforgettable ride — learning, networking, swag collecting, ...