Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HarikaGonela/6a382f451fd385fbf99a07a5584e2707 to your computer and use it in GitHub Desktop.
Save HarikaGonela/6a382f451fd385fbf99a07a5584e2707 to your computer and use it in GitHub Desktop.
Splunk Java SDK Example - Connect and Login to Splunk
/**
* Connect and Login to Splunk
*
* @return Service instance
*/
public static Service connectAndLoginToSplunkExample() {
ServiceArgs connectionArgs = new ServiceArgs();
connectionArgs.setHost("ubuntu-splunk");
connectionArgs.setUsername("admin");
connectionArgs.setPassword("splunk");
connectionArgs.setPort(8089);
// will login and save the session key which gets put in the HTTP Authorization header
Service splunkService = Service.connect(connectionArgs);
System.out.println("Auth Token : " + splunkService.getToken());
return splunkService;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment