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 App for Anomaly Detection End of Life Announcment

Q: What is happening to the Splunk App for Anomaly Detection?A: Splunk is officially announcing the ...

Aligning Observability Costs with Business Value: Practical Strategies

 Join us for an engaging Tech Talk on Aligning Observability Costs with Business Value: Practical ...

Mastering Data Pipelines: Unlocking Value with Splunk

 In today's AI-driven world, organizations must balance the challenges of managing the explosion of data with ...