There are times when you want to create events out of thin air. These events could come from a database query, a web service, or simply some code that generates data useful in a query. Just to illustrate the plumbing, we will make a random number generator.
You can find this example in ImplementingSplunkExtendingExamples/bin/random_generator.py:
import splunk.Intersplunk as si from random import randint keywords, options = si.getKeywordsAndOptions() def getInt(options, field, default): try: return int(options.get(field, default)) except Exception, e: #raise a user friendly exception raise Exception("%s must be an integer" % field) try: min = getInt(options, 'min', 0) max = getInt(options, 'max', 1000000) eventcount = getInt(options, ...