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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...