Splunk Search

Need help with python script to log into Splunk Cloud

NanSplk01
Path Finder

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.
Labels (1)
Tags (2)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

What is the error?

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

NanSplk01
Path Finder

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
Path Finder

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!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...