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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...