Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* 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
try {
myInput.attachWith(new ReceiverBehavior() {
public void run(OutputStream stream) throws IOException {
DateFormat dateFormat = new SimpleDateFormat(
"yyyy/MM/dd-HH:mm:ss");
for (int i = 0; i < 10; i++) {
String date = dateFormat.format(new Date());
String eventText = date + " msg=\"Splunk Conf Test Event\"\n";
stream.write(eventText.getBytes("UTF8"));
}
}
});
} catch (IOException e) {
}
}
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.