Splunk® Enterprise

Developing Dashboards, Views, and Apps for Splunk Web

Download manual as PDF

NOTE - Splunk version 4.x reached its End of Life on October 1, 2013. Please see the migration information.
This documentation does not apply to the most recent version of Splunk. Click here for the latest version.
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.

<block title="Add new credentials" endpoint="admin/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
Setup screen example using a custom endpoint
How to migrate 3.X apps to 4.1.X

This documentation applies to the following versions of Splunk® Enterprise: 4.3, 4.3.1, 4.3.2, 4.3.3, 4.3.4, 4.3.5, 4.3.6, 4.3.7 View the Article History for its revisions.

Was this documentation topic helpful?

Enter your email address, and someone from the documentation team will respond to you:

Please provide your comments here. Ask a question or make a suggestion.

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