Getting Data In

is it possible to have a custom command return json to splunk?

dominiquevocat
SplunkTrust
SplunkTrust

I have a RESTful webservice which returns me a fairly complex json. I wish to pass it as-is to splunk and hope for splunk toparse it into key=value pairs.

What do i have to do? I can not seem to find a sample 😕

Tags (2)
0 Karma
1 Solution

dominiquevocat
SplunkTrust
SplunkTrust

Surprisingly simple....

url="https://xxx/wapi/xxx"
values={'ip_address' : ipfield}
data = urllib.urlencode(values)

passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, USERNAME, PASSWORD)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
req = urllib2.Request(url, data)
pagehandle = urllib2.urlopen(req)

results=json.loads(pagehandle.read())
splunk.Intersplunk.outputResults( results )

View solution in original post

dominiquevocat
SplunkTrust
SplunkTrust

Surprisingly simple....

url="https://xxx/wapi/xxx"
values={'ip_address' : ipfield}
data = urllib.urlencode(values)

passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None, url, USERNAME, PASSWORD)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)
req = urllib2.Request(url, data)
pagehandle = urllib2.urlopen(req)

results=json.loads(pagehandle.read())
splunk.Intersplunk.outputResults( results )
Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...