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!

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...