Getting Data In

not able to connect to splunk web console

skr
Loves-to-Learn Lots

I am not able to connect to splunk web console using python sdk getting timedout error , I am suspecting port is not allowing, Could you please help

my code

--------------------------

import sys

import getpass

sys.path.append('splunk-sdk-python-1.6.16')

import splunklib.client as client

 

def setServer(hostname, splunkuser, splunkpassword):

    HOST = hostname

    PORT = 8089

    USERNAME = splunkuser

    PASSWORD = splunkpassword

    service = client.connect(host=HOST,port=PORT,username=USERNAME,password=PASSWORD)

 

    #for app in service.apps:

     #   print (app.name)

# Get the collection of users

    #users = service.users

     #    print(users)

 

if __name__ == "__main__":

    hostname = input("Enter Splunk Hostname/IP: ")

    splunkUser = input("Enter Splunk Admin Username: ")

    splunkPassword = getpass.getpass("Enter Splunk Admin Password: ")

    setServer(hostname, splunkUser, splunkPassword)

-----------------------------------------------------------------

output

-----------------------

#python3 test66.py

Enter Splunk Hostname/IP: prd-p-pivip.splunkcloud.com

Enter Splunk Admin Username: sc_admin

Enter Splunk Admin Password:

Traceback (most recent call last):

  File "/Users/sasikanth.bontha/test66.py", line 23, in <module>

    setServer(hostname, splunkUser, splunkPassword)

  File "/Users/sasikanth.bontha/test66.py", line 11, in setServer

    service = client.connect(host=HOST,port=PORT,username=USERNAME,password=PASSWORD)

  File "/usr/local/lib/python3.9/site-packages/splunklib/client.py", line 331, in connect

    s.login()

  File "/usr/local/lib/python3.9/site-packages/splunklib/binding.py", line 883, in login

    response = self.http.post(

  File "/usr/local/lib/python3.9/site-packages/splunklib/binding.py", line 1242, in post

    return self.request(url, message)

  File "/usr/local/lib/python3.9/site-packages/splunklib/binding.py", line 1259, in request

    response = self.handler(url, message, **kwargs)

  File "/usr/local/lib/python3.9/site-packages/splunklib/binding.py", line 1399, in request

    connection.request(method, path, body, head)

  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1257, in request

    self._send_request(method, url, body, headers, encode_chunked)

  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1303, in _send_request

    self.endheaders(body, encode_chunked=encode_chunked)

  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1252, in endheaders

    self._send_output(message_body, encode_chunked=encode_chunked)

  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1012, in _send_output

    self.send(msg)

  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 952, in send

    self.connect()

  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 1419, in connect

    super().connect()

  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/http/client.py", line 923, in connect

    self.sock = self._create_connection(

  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 843, in create_connection

    raise err

  File "/usr/local/Cellar/python@3.9/3.9.6/Frameworks/Python.framework/Versions/3.9/lib/python3.9/socket.py", line 831, in create_connection

    sock.connect(sa)

TimeoutError: [Errno 60] Operation timed out

Labels (1)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@skr 

It's looks TimeoutError. Can you please check whether the Splunk Instance is reachable or not. Just ping OR use curl for same.

 

0 Karma

skr
Loves-to-Learn Lots

@kamlesh_vaghela 

Not able to ping also

 

# ping prd-p-pivip.splunkcloud.com

PING ec2-54-158-75-102.compute-1.amazonaws.com (54.158.75.102): 56 data bytes

Request timeout for icmp_seq 0

Request timeout for icmp_seq 1

Request timeout for icmp_seq 2

Request timeout for icmp_seq 3

Request timeout for icmp_seq 4

Request timeout for icmp_seq 5

Request timeout for icmp_seq 6

Request timeout for icmp_seq 7

Request timeout for icmp_seq 8

Request timeout for icmp_seq 9

Request timeout for icmp_seq 10

Tags (1)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

Means your VM is not connected to internet,  You can verify it by doing ping to https://google.com also.  If it is just contact your admin to provide Internet connectivity 🙂 

  

0 Karma

skr
Loves-to-Learn Lots

@kamlesh_vaghela 

i am able to ping google.com 🙂

#ping google.com

PING google.com (142.250.76.174): 56 data bytes

64 bytes from 142.250.76.174: icmp_seq=0 ttl=118 time=27.841 ms

64 bytes from 142.250.76.174: icmp_seq=1 ttl=118 time=26.473 ms

64 bytes from 142.250.76.174: icmp_seq=2 ttl=118 time=29.327 ms

64 bytes from 142.250.76.174: icmp_seq=3 ttl=118 time=29.047 ms

64 bytes from 142.250.76.174: icmp_seq=4 ttl=118 time=30.789 ms

^C

--- google.com ping statistics ---

5 packets transmitted, 5 packets received, 0.0% packet loss

round-trip min/avg/max/stddev = 26.473/28.695/30.789/1.454 ms

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@skr 

I just notice one thing.  Can please check your access of Splunk cloud instance management port for API? May be 8089 port is not open.

Just check below link for more info.

https://docs.splunk.com/Documentation/Splunk/8.2.1/RESTTUT/RESTandCloud#Accessing_the_Splunk_Cloud_R...

 

KV

0 Karma

skr
Loves-to-Learn Lots

Hi @kamlesh_vaghela ,

 

Could you please check port 8089 from your end and open 

prd-p-pivip.splunkcloud.com

 

Note :I am using free trail splunk cloud

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@skr 

No I'm not able to access it. The reason being, when you ask Splunk Support to enable 8089 port, they will ask you to allowed IP list from 8089 port being called. 🙂 

0 Karma

skr
Loves-to-Learn Lots

@kamlesh_vaghela 

 

Can i give my local IP and ask splunk support team to open 8089 port ?

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

yes @skr 

To access your Splunk Cloud deployment using the Splunk REST API and SDKs, submit a case requesting access using the Splunk Support Portal. Splunk Support opens port 8089 for REST access. You can specify a range of IP addresses to control who can access the REST API.

0 Karma

skr
Loves-to-Learn Lots

@kamlesh_vaghela 

 

CaseSubmit a Case
  • Back  Back
 
It appears you do not have an active Support Contract or entitlement, and as a result, cannot open a Support case. If you believe this is an error, please contact Support via telephone using the region specific numbers found here.

All users are welcome to post questions and answers to https://answers.splunk.com.
Tags (1)
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@skr 

If  anyone in your organisation has active entitlement can raise support ticket for you.

 

0 Karma

skr
Loves-to-Learn Lots

Thank you so much for your help and support @kamlesh_vaghela 

 

Unfortunately no one having any access to this 😒.. i am learning alone.

0 Karma

skr
Loves-to-Learn Lots

@kamlesh_vaghela 

 

Any other way ??

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@skr 

Well you are learning then I suggest to install Splunk Enterprise in your local machine and get same experience of REST :). This is what I did and doing 🙂  . Click on Free Splunk on right top and enjoy learning.

Happy Splunking

🙂 

 

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...