Splunk Dev

Сustom search comand for java

sangears
New Member

I have an example of a custom python script for displaying events from db in the splunk, help with the same example how to do this for Java?

 

 

 

import sys, time
from splunklib.searchcommands import \
    dispatch, GeneratingCommand, Configuration, Option, validators

@Configuration()
class GenerateHelloCommand(GeneratingCommand):
    count = Option(require=True, validate=validators.Integer())

    def generate(self):
        for i in range(1, self.count + 1):
            text = 'Hello World %d' % i
            yield {'_time': time.time(), 'event_no': i, '_raw': text }

dispatch(GenerateHelloCommand, sys.argv, sys.stdin, sys.stdout, __name__) 

 

 

 

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

It doesn't say you can't use Java, but one of the prerequisites at https://dev.splunk.com/enterprise/docs/devtools/customsearchcommands/createcustomsearchcmd is the Splunk SDK for Python so I conclude you must use Python for custom commands.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...