Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple example to demonstrate using the Splunk Java SDK from Scala
package com.splunk.dev.javasdk.examples
import com.splunk.Service._
import scala.collection.mutable.HashMap
import scala.collection.JavaConversions._
/**
* Simple example to demonstrate using the Splunk Java SDK from Scala
* @author ddallimore
*/
object SplunkJavaSDKWrapper {
def main(args: Array[String]) = {
//connect and login
val connectionArgs = HashMap[String, Object]("host" -> "somehost", "username" -> "admin", "password" -> "foo")
val service = connect(connectionArgs)
//get Splunk Server info
val info = service.getInfo
// Scala/Java conversion
val javaSet = info.keySet
val scalaSet = javaSet.toSet
//print out Splunk Server info
for (key <- scalaSet)
println(key + ":" + info.get(key))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.