I want to connect my java program to Splunk Cloud and send logs there.
I tried to connect with Splunk enterprise (installing on my local machine). In this case it's connected successfully and I can see the logs there too.
I don't know why I'm unable to get connect my java program to Splunk Cloud.
My code looks like this.
Map<String, Object> connectArgs= new HashMap<String, Object>();
HttpService.setSslSecurityProtocol( SSLSecurityProtocol.TLSv1_2);
connectArgs.put("host", "xxx.splunkcloud.com"); //this is the part of the url what I found in the url of my splunk cloud account.
connectArgs.put("username", "un");
connectArgs.put("password", "pswd");
connectArgs.put("scheme", "https"); // I tried http also here
connectArgs.put("port", 8089); // I tried 8088 too nothing works
Service splunkService= Service.connect(connectArgs);
Args logArgs= new Args();
logArgs.put("sourcetype", "helloWorldSplunk");
Receiver receiver= splunkService.getReceiver();
receiver.log("main", logArgs, "Hello from java SDE program to Splunk");
System.out.println("END");
The error what I get while execuiting the above code =>
Exception in thread "main" java.lang.RuntimeException: Connection timed out: connect
at com.splunk.HttpService.send
Furthermore I've one more question here:
How to connect my JavaEE app to Splunk? Do I've same the procedure like I follow above? Or something different.