Splunk Search

Java SDK send data directly to Splunk (web)

tomspring5000
New Member

Hi,
I'm attempting to implement a direct connection to Splunk in my Java application so I can send data straight to Splunk without having to go through a forwarder. I've written some psuedocode, I just wanted to check if its correct:

import com.splunk.*;

//Connect to Splunk Service
ServiceArgs loginArgs = new ServiceArgs();
loginArgs.setUsername("admin");
loginArgs.setPassword("password");
loginArgs.setHost("localhost");
loginArgs.setPort(8089);
Service service = Service.connect(loginArgs);

Index myIndex = service.getIndexes().get("index_name");
Args eventArgs = new Args();
eventArgs.put("CaseName", caseName);
eventArgs.put("Result", result);
eventArgs.put("Runtime", runtime);
eventArgs.put("Environment", env);
eventArgs.put("postDate", date);

myIndex.submit(eventArgs);

Thanks,
Tom

0 Karma
Get Updates on the Splunk Community!

Splunk Answers Content Calendar, June Edition II

Get ready to dive into Splunk Dashboard panels this week! We'll be tackling common questions around ...

Splunk Observability Cloud's AI Assistant in Action Series: Auditing Compliance and ...

This is the third post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...