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!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...