Splunk® Enterprise

Developing Views and Apps for Splunk Web

Acrobat logo Download manual as PDF

Splunk Enterprise version 6.x is no longer supported as of October 23, 2019. See the Splunk Software Support Policy for details. For information about upgrading to a supported version, see How to upgrade Splunk Enterprise.
This documentation does not apply to the most recent version of Splunk. Click here for the latest version.
Acrobat logo Download topic as PDF

Setup screen example with user credentials

This example shows the steps needed to create a set up screen that accepts user/password credentials for a python script. The python script uses the credentials supplied in the setup screen.

  1. Create the block in your setup screen that accepts user credentials.
  2. Write a python script that uses the credentials
  3. Create a stanza in inputs.conf for your script.

1. Create a block in setup.xml that accepts user credentials

Add the following block to setup.xml to create the User input fields for your scripts. Place the block between setup tags.

<block title="Add new credentials" endpoint="storage/passwords" entity="_new">
  <input field="name">

  <input field="password">

  <!-- Remove the realm input field if your app is not using realm -->
  <input field="realm">

2. Write a python script that uses credentials

Here is the path to the example script:



import splunk.entity as entity

. . .

# access the credentials in /servicesNS/nobody/<MyApp>/admin/passwords
def getCredentials(sessionKey):
   myapp = 'name-of-your-app-here'
      # list all credentials
      entities = entity.getEntities(['admin', 'passwords'], namespace=myapp,
                                    owner='nobody', sessionKey=sessionKey)
   except Exception, e:
      raise Exception("Could not get %s credentials from splunk. Error: %s"
                      % (myapp, str(e)))

   # return first set of credentials
   for i, c in entities.items():
        return c['username'], c['clear_password']

   raise Exception("No credentials have been found")  

def main():
        # read session key sent from splunkd
        sessionKey = sys.stdin.readline().strip()

        if len(sessionKey) == 0:
           sys.stderr.write("Did not receive a session key from splunkd. " +
                            "Please enable passAuth in inputs.conf for this " +

        # now get twitter credentials - might exit if no creds are available
        username, password = getCredentials(sessionKey)

        # use the credentials to access the data source
        . . .

3. Create a stanza in inputs.conf

Here is the path to inputs.conf for the example:


Add the following stanza to inputs.conf:

. . .
passAuth   = splunk-system-user
Last modified on 18 August, 2016
Setup screen example using a custom endpoint
How to restrict your users to one app

This documentation applies to the following versions of Splunk® Enterprise: 6.3.0, 6.3.1, 6.3.2, 6.3.3, 6.3.4, 6.3.5, 6.3.6, 6.3.7, 6.3.8, 6.3.9, 6.3.10, 6.3.11, 6.3.12, 6.3.13, 6.3.14, 6.4.0, 6.4.1, 6.4.2, 6.4.3, 6.4.4, 6.4.5, 6.4.6, 6.4.7, 6.4.8, 6.4.9, 6.4.10, 6.4.11

Was this documentation topic helpful?

You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters