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!

Splunk Answers Content Calendar, June Edition

Get ready for this week’s post dedicated to Splunk Dashboards! We're celebrating the power of community by ...

What You Read The Most: Splunk Lantern’s Most Popular Articles!

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

See your relevant APM services, dashboards, and alerts in one place with the updated ...

As a Splunk Observability user, you have a lot of data you have to manage, prioritize, and troubleshoot on a ...