Skip to content

Instantly share code, notes, and snippets.

Damien Dallimore damiendallimore

View GitHub Profile
damiendallimore /
Last active Jul 23, 2019
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();
damiendallimore /
Created Aug 5, 2012
Simple examples to demonstrate using the SplunkJavaLogging framework
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 /
Created Nov 8, 2016
Custom output handler for wrapping Gogen with the Splunk Command Modular Input. Just add this class to command_ta/bin/
class GoGenHandler:
def __init__(self,**args):
self.index = args['index']
self.source = args['source']
self.sourcetype = args['sourcetype'] = args['host']
def __call__(self,raw_cmd_output):
print "<stream><event><data>%s</data><source>%s</source><sourcetype>%s</sourcetype><index>%s</index><host>%s</host></event></stream>" % (encodeXMLText(raw_cmd_output),self.source,self.sourcetype,self.index,
damiendallimore / Splunk_Search_Java_Stacktace
Created Sep 12, 2013
Splunk Search for Java Exception Stacktrace events formatted by Splunk Java Logging
View Splunk_Search_Java_Stacktace
index=main sourcetype=logback throwable_class | makemv delim="," stacktrace_elements | table _time throwable_message throwable_class stacktrace_elements
damiendallimore /
Created Aug 5, 2012
Example logging framework configuration files for using SplunkJavaLogging REST/Raw TCP appenders
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 /
Created Oct 17, 2014
Custom Splunk JMS Modular Input message handler to output just the message payload
package com.splunk.modinput.jms.customhandler;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.jms.Message;
import com.splunk.modinput.Stream;
import com.splunk.modinput.StreamEvent;
damiendallimore / listEvents_example.txt
Created Nov 12, 2013
Example Splunk REST API stanza settings for polling the Cloudstack listEvents API endpoint.
View listEvents_example.txt
Endpoint URL
HTTP Method
Authentication Type
damiendallimore /
Created Nov 12, 2013
Custom Auth handler that the Splunk REST API Modular Input can use to connect to the Cloudstack REST API
from requests.auth import AuthBase
import hmac
import base64
import hashlib
import urlparse
import urllib
class CloudstackAuth(AuthBase):
def __init__(self,**args):
damiendallimore / Splunk_Search_Splunk_Java_Agent_Method_Analysis
Last active Dec 22, 2015
Splunk Search for method tracing events collected by Splunk Java Agent
View Splunk_Search_Splunk_Java_Agent_Method_Analysis
index=main sourcetype=splunk-java-agent name=method* | transaction appName,threadID,className,methodName startswith="method_entered" endswith="method_exited" | stats min(duration) as "Min Execution Time" max(duration) as "Max Execution Time" avg(duration) as "Avg Execution Time" count as "Total Calls" sum(duration) as "Cumulative Execution Time" by className,methodName
* Stream some data to Splunk over raw TCP
private static void tcpInputDataExample() {
Service splunkService = connectAndLoginToSplunkExample();
// Retrieve the input
TcpInput myInput = (TcpInput) splunkService.getInputs().get("5153");
// Open the socket and stream
You can’t perform that action at this time.