There are multiple ways to access config items from with custom search commands. The easiest one is to use the splunk.clilib.cli_common
from splunk.clilib import cli_common as cli
...
cfg = cli.getConfStanza('myconf','mystanza')
print cfg.get('myitem')
The alternative is to actually access the configuration via REST. You can setup the search command to retrieve an auth token via STDIN when it's called by setting passauth = true in commands.conf ( enableheader has to be set to true as well).
import splunk.entity, splunk.Intersplunk
...
settings = dict()
records = splunk.Intersplunk.readResults(settings = settings, has_header = True)
...
entity = splunk.entity.getEntity('/admin/conf-myconf','mystanza', namespace='myapp', sessionKey=settings['sessionKey'], owner='nobody')
print entity.get('myitem')
Retrieving the config via REST is the cleaner way IMO. It additionally gives you control over app/user namespace when reading the configuration.
... View more