Knowledge Management

custom config values in workflow UI?

caphrim007
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

caphrim007
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

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

0 Karma
Get Updates on the Splunk Community!

ATTENTION!! We’re MOVING (not really)

Hey, all! In an effort to keep this Slack workspace secure and also to make our new members' experience easy, ...

Splunk Admins: Build a Smarter Stack with These Must-See .conf25 Sessions

  Whether you're running a complex Splunk deployment or just getting your bearings as a new admin, .conf25 ...

AppDynamics Summer Webinars

This summer, our mighty AppDynamics team is cooking up some delicious content on YouTube Live to satiate your ...