Splunk Dev

Python SDK ValueError: Invalid IPv6 URL

arvindlavania
New Member

Hello,

I am trying to connecting my Splunk server via Python SDK

Code:
import splunklib.client as client
service = client.connect(host='https://website.com', port=443,
scheme='https', username='mineuser', password='xxxxxxxxxxx')
assert isinstance(service, client.Service)

Error:
Traceback (most recent call last):
File "search.py", line 116, in
main(sys.argv[1:])
File "search.py", line 73, in main
service = client.connect(**kwargs_splunk)
File "../splunklib/client.py", line 333, in connect
s.login()
File "../splunklib/binding.py", line 873, in login
cookie="1") # In Splunk 6.2+, passing "cookie=1" will return the "set-cookie" header
File "../splunklib/binding.py", line 1225, in post
return self.request(url, message)
File "../splunklib/binding.py", line 1242, in request
response = self.handler(url, message, **kwargs)
File "../splunklib/binding.py", line 1367, in request
scheme, host, port, path = _spliturl(url)
File "../splunklib/binding.py", line 1072, in _spliturl
parsed_url = urllib.parse.urlparse(url)
File "/usr/local/Cellar/python@2/2.7.16_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urlparse.py", line 143, in urlparse
tuple = urlsplit(url, scheme, allow_fragments)
File "/usr/local/Cellar/python@2/2.7.16_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urlparse.py", line 214, in urlsplit
raise ValueError("Invalid IPv6 URL")
ValueError: Invalid IPv6 URL

What i am doing wrong, Help Please.

Python 2.7.16

Labels (2)
0 Karma

harsmarvania57
Ultra Champion

Hi,

You are using wrong port number while trying to connect to Splunk using Python SDK. You need to use splunk management port (default is 8089) and in host you need to just provide hostname or IP address (Do not pass http:// or https://)

Have alook at example here https://dev.splunk.com/enterprise/docs/python/sdk-python/howtousesplunkpython/howtoconnectpython/

0 Karma
Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...