Getting Data In

Host attribute for com.splunk.Index.upload in java SDK

tanmaybalwa
Engager

Is there a way to pass host attribute value for oneshot upload in java sdk for splunk?

The example on splunk documentation shows that valid parameters for oneshot upload include both host_regex and host.

Any way I can set it for index.upload? The only parameter that it currently accepts is the path of the file to be uploaded

Thanks!

0 Karma
1 Solution

ineeman
Splunk Employee
Splunk Employee

Thank you for reporting this. This is a current limitation of the SDK, but I went and filed a bug for it here:
https://github.com/splunk/splunk-sdk-java/issues/58

You can track the status there, and I'll also update here when we've fixed it.

In the meantime, your proposed fix would work. You should feel free to make a local change to the SDK and compile it until we've fixed it in the official version.

View solution in original post

ineeman
Splunk Employee
Splunk Employee

Thank you for reporting this. This is a current limitation of the SDK, but I went and filed a bug for it here:
https://github.com/splunk/splunk-sdk-java/issues/58

You can track the status there, and I'll also update here when we've fixed it.

In the meantime, your proposed fix would work. You should feel free to make a local change to the SDK and compile it until we've fixed it in the official version.

tanmaybalwa
Engager

Thanks for blessing the change! Will proceed with compiling the SDK with the modification.

0 Karma

tanmaybalwa
Engager

I saw the source for upload:
public void upload(String filename) {
EntityCollection uploads = service.getUploads();
Args args = new Args("index", getName());
uploads.create(filename, args); }

I think that the change should be:
public void upload(String filename, String hostname) {
EntityCollection uploads = service.getUploads();
Args args = new Args("index", getName());
Args.put("host", hostname);
uploads.create(filename, args); }
Would this work?

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...