- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how to create splunk custom search command with java ?
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Does anyone know if this is possible. Based on the documentation, I don't think it's possible to create a custom search command in Java. It would have to be done with python
custom command documentation for python:
https://dev.splunk.com/enterprise/docs/devtools/customsearchcommands/customsearchcmdexamples/
I went through the docs for Java and there's nothing in regards to custom commands
https://dev.splunk.com/enterprise/docs/devtools/java/plugin-eclipse/howtouseeclipse
splunk employees, can you help confirm?
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

You need to use Splunk Java SDK. Very good documentation at: Splunk Java SDK documentation
The core logic being..
// Create the job
JobArgs jobArgs = new JobArgs();
jobArgs.setEarliestTime("rt-1m");
String mySearch = "search index=_internal";
Job job = service.search(mySearch, jobArgs);
// View the results--a stream of previews--using standard Java classes
JobResultsPreviewArgs previewArgs = new JobResultsPreviewArgs();
InputStream stream = job.getResultsPreview(previewArgs);
BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi koshyk
Thnx. i tried that one too but my requirement is i need to process those results and post back to splunk preview and this search has to work dynamically that means the input has to come from splunk search bar. this entire work has to be done with java
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

don't think i quite understood. Is this what you are trying to do ?
- run search1 & get results of search1
- create search2 with results of search1
(you said, you got examples in python. if you put that, i might look to convert to java)
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need the following to be converted to java and run in splunk
Thanks InAdvance
http://docs.splunk.com/Documentation/Splunk/6.2.4/AdvancedDev/SearchScripts
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

that's bit of complex sample in that.
But found a simpler example at: splunk.blogs
https://github.com/splunk/splunk-sdk-python/tree/develop/examples/searchcommands_app
https://github.com/splunk/splunk-sdk-python/blob/develop/examples/searchcommands_app/bin/generatehel...
which you can convert to java
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I need those in Java. Even though i convert code i don't have an idea whether it works or not
- Mark as New
- Bookmark Message
- Subscribe to Message
- Mute Message
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
any luck finding out if you can create custom search commands using Java?
