Getting Data In

JAVA SDK exception for remote upload of file

tanmaybalwa
Engager

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)
    .....
0 Karma
1 Solution

Damien_Dallimor
Ultra Champion

You are correct with your understanding of how oneshot works :

REST API Oneshot Upload Docs

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.

View solution in original post

tanmaybalwa
Engager

Thank you.

0 Karma

Damien_Dallimor
Ultra Champion

adjusted your formatting.

0 Karma

Damien_Dallimor
Ultra Champion

You are correct with your understanding of how oneshot works :

REST API Oneshot Upload Docs

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.

tanmaybalwa
Engager

the formatting tools are not showing the path correctly but I made sure that the path to file is correct and file exists

0 Karma
Get Updates on the Splunk Community!

Celebrating the Winners of the ‘Splunk Build-a-thon’ Hackathon!

We are thrilled to announce the winners of the Splunk Build-a-thon, our first-ever hackathon dedicated to ...

Why You Should Register for Splunk University at .conf25

Level up before .conf25 even begins Splunk University is back in Boston, September 6–8, and it’s your chance ...

Building Splunk proficiency is a marathon, not a sprint

Building Splunk skills is a lot like training for a marathon. It’s about consistent progress, celebrating ...