添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
潇洒的葡萄  ·  Implement cluster ...·  1 周前    · 
爱旅游的保温杯  ·  AWS SQS Input - ...·  2 周前    · 
拉风的蘑菇  ·  Solved: How to add a ...·  1 月前    · 
安静的李子  ·  Solved: How to create ...·  1 月前    · 
年轻有为的双杠  ·  MQTT Modular Input - ...·  2 月前    · 
高大的金针菇  ·  《无颜之月樱花》- ...·  4 周前    · 
独立的椰子  ·  滚动新闻-中新网·  3 月前    · 
干练的西装  ·  Offer Mysql 5.6 on ...·  11 月前    · 

I'm trying to connect to the Splunk REST API and am running into errors. Not sure what to do from here...
Code:

import splunklib.client as client
service = client.connect(
    host="192.168.50.251",
    scheme="http",
    username="username",
    password="password"

I am able to log into the Splunk web interface using these credentials, but when trying with the python API I get:

Traceback (most recent call last):
  File "splunk_testing.py", line 9, in <module>
    password="dev"
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/splunklib/client.py", line 321, in connect
    s.login()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/splunklib/binding.py", line 847, in login
    cookie="1") # In Splunk 6.2+, passing "cookie=1" will return the "set-cookie" header
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/splunklib/binding.py", line 1185, in post
    return self.request(url, message)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/splunklib/binding.py", line 1202, in request
    response = self.handler(url, message, **kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/splunklib/binding.py", line 1339, in request
    response = connection.getresponse()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1132, in getresponse
    response.begin()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 453, in begin
    version, status, reason = self._read_status()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 409, in _read_status
    line = self.fp.readline(_MAXLINE + 1)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 480, in readline
    data = self._sock.recv(self._rbufsize)
socket.error: [Errno 54] Connection reset by peer

We're running Splunk 6.3.0 and I'm using splunk-sdk (Py lib) v1.5.0. The management port is set to 8089, so I think this should work. Am I doing something wrong?

Splunk, Splunk>, Turn Data Into Doing, Data-to-Everything, and D2E are trademarks or registered trademarks of Splunk Inc. in the United States and other countries. All other brand names, product names, or trademarks belong to their respective owners.