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!

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...