Splunk SDK for Python Utilities

This topic describes an optional utility you can use with the Splunk SDK for Python.  

Save login credentials for examples and unit tests

To connect to Splunk, all of the SDK examples and unit tests take command-line arguments that specify values for the host, port, and login credentials for Splunk. For convenience during development, you can store these arguments as key-value pairs in a text file named .splunkrc. Then, when you don't specify these arguments at the command line, the SDK examples and unit tests use the values from the .splunkrc file.

To set up a .splunkrc file:

  1. Create a text file with the following format:
    # Splunk host (default: localhost)
    host=localhost
    # Splunk admin port (default: 8089)
    port=8089
    # Splunk username
    username=admin
    # Splunk password
    password=changeme
    # Access scheme (default: https)
    scheme=https
    # Your version of Splunk (default: 5.0)
    version=6.4.2
    
  2. Save the file as .splunkrc in the current user's home directory.

    On Windows

    • Save the file as:

      C:\Users\currentusername\.splunkrc

      You might get errors in Windows when you try to name the file because .splunkrc looks like a nameless file with an extension. You can use the command line to create this file—go to the C:\Users\currentusername directory and enter the following command:

      Notepad.exe .splunkrc

      Click Yes, then continue creating the file.

    On *nix, including OS X

    • Save the file as:

      ~/.splunkrc

Notes:

  • Storing login credentials in the .splunkrc file is only for convenience during development—this file isn't part of the Splunk platform and shouldn't be used for storing user credentials for production. And, if you're at all concerned about the security of your credentials, just enter them at the command line and don't bother using the .splunkrc file.
  • The format of the .splunkrc file has changed between releases. If you are using a preview or beta version of the SDK, some of the newer fields might not be recognized and you might see errors while running the examples. You can either update to the latest version of the SDK, or comment out the app, owner, and version fields.
  • The version field is only used by the Splunk SDK for JavaScript.

For troubleshooting information about the .splunkrc file, see "Troubleshooting".