During this last weekend I found myself up to my knees in splunk modding that ya just don't do every day.

Splunk's documentation is leaps and bounds beyond where it was a couple revs ago, and their answers.splunk.com site is extremely useful.

Of course, there are going to be cases like mine, that you can't expect to be covered by documentation. For this particular mod, I needed to be able to retrieve a set of configuration parameters from a custom application config file.

Splunk has documentation on custom config endpoints, and the docs match what the software does. Great.

When it comes to getting those config values out of the file and back into the UI though, that's a black art. I looked through the Javascript and Python code that the UI is composed of and saw no obvious way to do that. So here's how I did it.

First, you need to add a ServerSideInclude in your view

include.html

</pre>
Then, in the include.html (which should reside in your apps appserver/static/ directory) you can include the following code which leverages internal splunk stuff that I found in various source files.

< %
import splunk.bundle as bundle

retDict = {}
try:
thing = bundle.getConf('myapp', namespace="MyApp")
for s in thing:
retDict[s] = {}
retDict[s].update(thing[s].items())
except splunk.ResourceNotFound:
pass

%>

<input name="AppUsername" type="hidden" value="${retDict[" />
<input name="AppPassword" type="hidden" value="${retDict[" />
<input name="AppHostname" type="hidden" value="${retDict[" />
<input name="AppPort" type="hidden" value="${retDict[" /></div>

</pre>
Your app specific config file, in this case myapp.conf is located at local/myapp.conf and the contents of it are populated into the retDict</code> variable.

Sample contents of local/myapp.conf

[appliance]
username = myuser
password = mypassword
hostname = my.host.org
port = 443
</pre>
The end result of this is that you can get creative in your application.js</code> file; being able to use the values that you save via setup.xml to your custom app config file.

I'd still be interested to know if there is a better way to go about getting those custom configs, but until such time, this method works fine.