Security

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

MarcHelou
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

s2_splunk
Splunk Employee
Splunk Employee

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

0 Karma

woodcock
Esteemed Legend
0 Karma

MarcHelou
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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

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

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...