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!

The Payment Operations Wake-Up Call: Why Financial Institutions Can't Afford ...

The same scenario plays out across financial institutions daily. A payment system fails at 11:30 AM on a busy ...

Make Your Case: A Ready-to-Send Letter for Getting Approval to Attend .conf25

Hello Splunkers, Want to attend .conf25 in Boston this year but not sure how to convince your manager? We've ...

Community Spotlight: A Splunk Expert's Journey

In the world of data analytics, some journeys leave a lasting impact not only on the individual but on the ...