Hi ,
Here I will resolve that issue ,
Follow that step
public class SplunkConnection {
public String secureConnection() throws JSONException, IOException{
HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);
Map <String,Object> connectionArgs = new HashMap<String,Object>();
connectionArgs.put("host", "DEVELOPMENT");
connectionArgs.put("username", "admin");
connectionArgs.put("password", "*****");
connectionArgs.put("port", 8089);
connectionArgs.put("scheme", "https");
Service splunkService = Service.connect(connectionArgs);
Args queryArgs = new Args();
queryArgs.put("earliest_time","0");
queryArgs.put("latest_time","now");
Job job = splunkService.getJobs().create("search index=*");
while(!job.isDone()){
try{
Thread.sleep(500);
}catch (Exception exp){
exp.printStackTrace();
}
}
try{
Args outputArgs = new Args();
outputArgs.put("output_mode", "json");
InputStream inputStream = job.getResults(outputArgs);
byte[] buffer = new byte[4096];
String json= "";
while(inputStream.read(buffer)!= -1){
json = new String(buffer);
logger.info(json );
}
return json;
} catch(Exception e){
e.printStackTrace();
}
return null;
}
}
Thank you,
If you get any issue please let me know.
... View more