Skip to content

Instantly share code, notes, and snippets.

Avatar

Damien Dallimore damiendallimore

View GitHub Profile
@damiendallimore
damiendallimore / SplunkJavaSDKWrapper.groovy
Created Aug 5, 2012
Simple example to demonstrate using the Splunk Java SDK from Groovy
View SplunkJavaSDKWrapper.groovy
package com.splunk.dev.javasdk.examples
import com.splunk.Entity;
import com.splunk.Service;
import com.splunk.ServiceInfo;
/**
* Simple example to demonstrate using the Splunk Java SDK from Groovy
* @author ddallimore
*
@damiendallimore
damiendallimore / SplunkJavaSDKWrapper.scala
Created Aug 5, 2012
Simple example to demonstrate using the Splunk Java SDK from Scala
View SplunkJavaSDKWrapper.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
*/
@damiendallimore
damiendallimore / SplunkJavaLoggingExamples.java
Created Aug 5, 2012
Simple examples to demonstrate using the SplunkJavaLogging framework
View SplunkJavaLoggingExamples.java
package com.splunk.dev.logging.examples;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.dtdsoftware.splunk.logging.SplunkLogEvent;
import com.dtdsoftware.splunk.logging.SplunkLogEventFactory;
/**
* Simple examples to demonstrate using the SplunkJavaLogging framework
@damiendallimore
damiendallimore / jdklogging.properties
Created Aug 5, 2012
Example logging framework configuration files for using SplunkJavaLogging REST/Raw TCP appenders
View jdklogging.properties
handlers = com.dtdsoftware.splunk.logging.jdk.handler.SplunkRestHandler
#handlers = com.dtdsoftware.splunk.logging.jdk.handler.SplunkRawTCPHandler
# Set the default logging level for the root logger
.level = INFO
# Set the default logging level for the splunk logger
splunk.logger = INFO
# Set the default logging level for new SplunkRestHandler instances
@damiendallimore
damiendallimore / ConnectAndLoginToSplunkExample.java
Last active Jul 23, 2019
Splunk Java SDK Example - Connect and Login to Splunk
View ConnectAndLoginToSplunkExample.java
/**
* Connect and Login to Splunk
*
* @return Service instance
*/
public static Service connectAndLoginToSplunkExample() {
ServiceArgs connectionArgs = new ServiceArgs();
connectionArgs.setHost("ubuntu-splunk");
connectionArgs.setUsername("admin");
@damiendallimore
damiendallimore / ClientServerStateExample.java
Last active Oct 8, 2015
Splunk Java SDK Example - Client/Server state
View ClientServerStateExample.java
/**
* Set an Entity's property locally then update the state to the Splunk
* server
*/
public static void pushStateToServerExample() {
Service splunkService = connectAndLoginToSplunkExample();
EventTypeCollection eventTypeCollection = splunkService.getEventTypes();
EventType eventType = eventTypeCollection.create("test",
@damiendallimore
damiendallimore / TCPInputCreateRemoveExample.java
Last active Oct 8, 2015
Splunk Java SDK Example - Create/Remove TCPInput
View TCPInputCreateRemoveExample.java
/**
* Create a TCPInput in a specific namespace Will use the /servicesNS path
*/
public static void tcpInputCreateExample() {
Service splunkService = connectAndLoginToSplunkExample();
String tcpPort = "5150";
Args args = new Args();
args.put("owner", "admin");
View GetServerInfoExample.java
/**
* Simple example that gets Splunk server info and settings
*/
public static void getServerInfoExample() {
Service splunkService = connectAndLoginToSplunkExample();
ServiceInfo info = splunkService.getInfo();
System.out.println("Info:");
for (String key : info.keySet())
View OneshotBlockingSearchExample.java
/**
* Oneshot search, no job is created exec_mode = oneshot , blocking
*/
public static void oneshotBlockingSearchExample() {
Service splunkService = connectAndLoginToSplunkExample();
String searchQuery = "search index=_internal * | head 1";
JobArgs queryArgs = new JobArgs();
queryArgs.setEarliestTime("-1d@d");
View SimpleBlockingSearchExample.java
/**
* Simple Search exec_mode = blocking , blocking
*/
public static void simpleBlockingSearchExample() {
Service splunkService = connectAndLoginToSplunkExample();
String searchQuery = "search index=_internal * | head 1";
JobArgs queryArgs = new JobArgs();
queryArgs.setEarliestTime("-3d@d");
You can’t perform that action at this time.