Experts,
This could be expected behavior but the SDK documentation doesn't mention that the index.upload is supposed to work for only paths local to the server running splunk instance.
I tried to use index.upload against splunk instance running on the same server and there is no exception. But when i try the same code for remote server there is a file not found exception.
If this an accepted behavior then my question is what is the equivalent way to upload a file to remote server (because the Splunk Web works perfect for remote file uploads too)
Thanks!
[Fatal Error] :1:1: Premature end of file.
com.splunk.HttpException: HTTP 400 -- <?xml version="1.0" encoding="UTF-8"?>
<response>
<messages>
<msg type="ERROR">In handler 'oneshotinput': unable to open file: path='C:\Users\tanmay\Downloads\20131208_test.tar.gz' error='No such file or directory'</msg>
</messages>
</response>
at com.splunk.HttpException.create(HttpException.java:84)
at com.splunk.HttpService.send(HttpService.java:386)
at com.splunk.Service.send(Service.java:1261)
at com.splunk.HttpService.post(HttpService.java:243)
at com.splunk.EntityCollection.create(EntityCollection.java:95)
at com.splunk.Index.upload(Index.java:1111)
.....
You are correct with your understanding of how oneshot works :
To perform a local file upload with the Java SDK, you will need to read in the file contents into your local Java program and then send these contents to Splunk. The simplest option for sending the file contents to Splunk would be via the receivers/simple endpoint using the submit method of the Index class. You could also stream the file contents to Splunk via a TCP socket that you have opened in Splunk using the attachWith method of the TcpInput class.There are code examples here for these and other data uploading approaches.
Thank you.
adjusted your formatting.
You are correct with your understanding of how oneshot works :
To perform a local file upload with the Java SDK, you will need to read in the file contents into your local Java program and then send these contents to Splunk. The simplest option for sending the file contents to Splunk would be via the receivers/simple endpoint using the submit method of the Index class. You could also stream the file contents to Splunk via a TCP socket that you have opened in Splunk using the attachWith method of the TcpInput class.There are code examples here for these and other data uploading approaches.
the formatting tools are not showing the path correctly but I made sure that the path to file is correct and file exists