Knowledge Management

custom config values in workflow UI?

Path Finder

I was wondering if it were possible to use $variable$ items in workflow actions that you have stored in a custom config file, or is it limited to backend scripts and *_renderers.

If it is possible, how does one go about referencing them?

Tags (1)
0 Karma
1 Solution

Path Finder

After perusing through the various Splunk.* javascript libraries, I think the answer is "no" so as a workaround one can do the following and achieve the desired effect.

Add a ServerSideInclude module in your view

<module name="ServerSideInclude" layoutPanel="appHeader">
  <param name="src">include.html</param>
</module>

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

%>

<div id='AppConfig'>
  <input type='hidden' name='AppUsername' value='${retDict['appliance']['username']}'>
  <input type='hidden' name='AppPassword' value='${retDict['appliance']['password']}'>
  <input type='hidden' name='AppHostname' value='${retDict['appliance']['hostname']}'>
  <input type='hidden' name='AppPort' value='${retDict['appliance']['port']}'>
</div>

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 variable.

Sample contents of local/myapp.conf

[appliance]
username = myuser
password = mypassword
hostname = my.host.org
port = 443

The end result of this is that you can get creative in your application.js file; being able to use the values that you save via setup.xml to your custom app config file.

Still interested to know if there is a better way to go about getting those custom configs.

View solution in original post

0 Karma

Path Finder

After perusing through the various Splunk.* javascript libraries, I think the answer is "no" so as a workaround one can do the following and achieve the desired effect.

Add a ServerSideInclude module in your view

<module name="ServerSideInclude" layoutPanel="appHeader">
  <param name="src">include.html</param>
</module>

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

%>

<div id='AppConfig'>
  <input type='hidden' name='AppUsername' value='${retDict['appliance']['username']}'>
  <input type='hidden' name='AppPassword' value='${retDict['appliance']['password']}'>
  <input type='hidden' name='AppHostname' value='${retDict['appliance']['hostname']}'>
  <input type='hidden' name='AppPort' value='${retDict['appliance']['port']}'>
</div>

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 variable.

Sample contents of local/myapp.conf

[appliance]
username = myuser
password = mypassword
hostname = my.host.org
port = 443

The end result of this is that you can get creative in your application.js file; being able to use the values that you save via setup.xml to your custom app config file.

Still interested to know if there is a better way to go about getting those custom configs.

View solution in original post

0 Karma
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!