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!

Sending Metrics to Splunk Enterprise With the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. The OpenTelemetry project is the second largest ...

What's New in Splunk Cloud Platform 9.0.2208?!

Howdy!  We are happy to share the newest updates in Splunk Cloud Platform 9.0.2208! Analysts can benefit ...

Want a chance to win $500 to the Splunk shop? Take our IT Incident Management Survey!

  Top Trends & Best Practices in Incident ManagementSplunk is partnering up with Constellation Research to ...