Created
July 23, 2019 10:29
-
-
Save HarikaGonela/6a382f451fd385fbf99a07a5584e2707 to your computer and use it in GitHub Desktop.
Splunk Java SDK Example - Connect and Login to Splunk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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