Reporting
Highlighted

Trouble using Export API for streaming data

Explorer

I'm using export API for streaming the data. The use case is : I want to open a stream for a search query and want to push the data outside splunk. I'm hoping that export API will stream the live data as it gets indexed in splunk and will remain live. Is it the right way to approach ?

code snippet
kwargsexport = {
"earliest
time": "-15m",
"latesttime": "now",
"search
mode": "normal",
"outputmode" : "csv",
"auto
cancel" : 0,
"autofinalizeec" : 0,
"autopause" : 0
}
searchquery
export = "search " + self.search
exportsearchresults = self.request.service.jobs.export(searchqueryexport, **kwargsexport)
reader = results.ResultsReader(exportsearch
results)

Tags (1)
0 Karma
Highlighted

Re: Trouble using Export API for streaming data

SplunkTrust
SplunkTrust

I'm not sure if this will work, but you will at least have to turn your search into a real-time search if you want the search to "remain live". As it is now, you will search for data from the last fifteen minutes once and then be finished.

0 Karma
Highlighted

Re: Trouble using Export API for streaming data

Explorer

So, which api should I use for realtime search ?

0 Karma
Highlighted

Re: Trouble using Export API for streaming data

SplunkTrust
SplunkTrust

The Python (I guess...) SDK's export API works for real-time searches, you need to specify appropriate values for earliest_time and latest_time such as rt-15m and rt.

http://dev.splunk.com/view/python-sdk/SP-CAAAEE5#exportsearch

0 Karma
Highlighted

Re: Trouble using Export API for streaming data

Explorer

I'm using following config but nothing was returned from export API.
kwargsexport = {
"earliest
time": "rt-15m",
"latesttime": "rt",
"search
mode": "normal",
"outputmode" : "csv",
"auto
cancel" : 0,
"autofinalizeec" : 0,
"autopause" : 0
}
searchquery
export = "search \"auto-0037.1\" | dedup val2 | table time,val1,val2"
exportsearchresults = service.jobs.export(searchqueryexport, **kwargsexport)
reader = results.ResultsReader(exportsearch
results)

reader is returned always empty

0 Karma