Security
Highlighted

Can you directly publish data from your Java application to Splunk Web?

New Member

Hello there,
I want to try and catch the spl query submitted on the web interface in my java application, process this query and get the data it wants, and them publish this data from my java application to the web interface.
All this should happen in the background so the user can't know that my script got his query and that my script will return his search. is it possible?
and one more question, I have splunk on docker and I downloaded the java sdk,
if i execute this command :
curl -u admin:xxxx -k https://localhost:8089/services/auth/login -d username=admin -d password=xxxx
i get a session token reply.
if I try to connect from the java application I get an handshake_failure
Thanks in advance,
I hope someone can help me.
PS:

this is the java code

package hellosplunk;

import com.splunk.Service;
import com.splunk.ServiceArgs;

public class helloSplunk {

public static void main(String[] args) {
    // TODO Auto-generated method stub
     ServiceArgs loginArgs = new ServiceArgs();
     loginArgs.setUsername("admin");
     loginArgs.setPassword("xxxx");
     loginArgs.setHost("localhost");
     loginArgs.setPort(8089);
     loginArgs.setScheme("https");

     Service splunkService = Service.connect(loginArgs);

     System.out.println(splunkService.getToken());


}

}

0 Karma
Highlighted

Re: Can you directly publish data from your Java application to Splunk Web?

Esteemed Legend
0 Karma
Highlighted

Re: Can you directly publish data from your Java application to Splunk Web?

New Member

Thanks for the reply,
that is not exactly what i am searching for unless I didnt understand the documentation.
in other word what i want is that everytime an spl query is made, it triggers my java application, and sends the query to my java app, this app performs the query and with the returned results, my java app posts them [the results] back to the splunk web interface.

so let's say:
1- you searched : index=_audit
2- the query goes to the java app
3- the java contact the splunkd
4- splunkd returns results to the java
5- the java posts the result back to the web interface

I want to know if that is possible or not
Thanks

0 Karma
Highlighted

Re: Can you directly publish data from your Java application to Splunk Web?

Splunk Employee
Splunk Employee

This is a perfect use case for the Splunk HTTP Event collector and/or Splunk logging for Java.

0 Karma