Getting Data In

Setup screen with credentials and multiple endpoints

andrew_garvin
Path Finder

I am trying to create a setup screen for my app that will store passwords securely and also create a scripted input in inputs.conf. I want the setup screen to have only three fields (host, username, password). I want those three fields to be input into admin/passwords as realm=host, name=username, and password=password. At the same time, I want to create a new scripted input that would look something like: [script://MyScript.py host].

The script is already configured to pull the username and password from admin/passwords using the host parameter to identify the correct realm. This is necessary because there will be multiple scripts running against different hosts that will potentially have different usernames and passwords.

I have the setup.xml below working. It correctly inputs a new host/username/password combination and the script can read that successfully. But, I have to manually create the script entry in inputs.conf. How can I have the setup store the password securely and also create the scripted input in inputs.conf at the same time? Do I have to use a custom endpoint for that? If so, how can a custom endpoint write a password to admin/passwords?

<setup>
<block title="Add new host" endpoint="admin/passwords" entity="_new">
<input field="realm">
<label>Host</label>
<type>text</type>
</input>
<input field="name">
<label>Username</label>
<type>text</type>
</input>
<input field="password">
<label>Password</label>
<type>password</type>
</input>
</block>
</setup>

References:
http://docs.splunk.com/Documentation/Splunk/latest/Developer/SetupExampleCredentials

1 Solution

hexx
Splunk Employee
Splunk Employee

The example that you should attempt to follow is probably this one.

As stated on that document, the general steps are as follows:

  • Create a stanza in restmap.conf that maps your endpoint
  • Write a python script that initializes your setup screen and handles the user-entered values.
  • Write setup.xml.

The bulk of the work will be writing the python of the custom REST endpoint that setup.xml will call to perform the two actions you need:

  • A POST to the /services/storage/passwords REST endpoint to store the username and password entered by the user. See this topic for the specifications of that endpoint.

  • A POST to the /services/data/inputs/script REST endpoint to create the scripted input. See this topic for the specifications of that endpoint.

View solution in original post

hexx
Splunk Employee
Splunk Employee

The example that you should attempt to follow is probably this one.

As stated on that document, the general steps are as follows:

  • Create a stanza in restmap.conf that maps your endpoint
  • Write a python script that initializes your setup screen and handles the user-entered values.
  • Write setup.xml.

The bulk of the work will be writing the python of the custom REST endpoint that setup.xml will call to perform the two actions you need:

  • A POST to the /services/storage/passwords REST endpoint to store the username and password entered by the user. See this topic for the specifications of that endpoint.

  • A POST to the /services/data/inputs/script REST endpoint to create the scripted input. See this topic for the specifications of that endpoint.

rmk12a
New Member
0 Karma

joe_kraxner
Explorer
0 Karma

andrew_garvin
Path Finder

Thank you hexx! This is what I needed. I got it working by using a couple setEntity() functions in the python to create both entries.

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Quantify Your Splunk Investment Impact: Introducing Savings Metrics to Value Insights

Building on the foundation established in our initial Value Insights releases, we are introducing the Savings ...

Event Series: Telemetry Pipeline Management

Balancing Scale and Spend: Gaining Control Over High-Volume Metrics in Splunk Observability Cloud As ...

Kick the Tires Before You Commit: A Hands-On Tour of the Splunk Observability Cloud ...

Evaluating an enterprise observability platform usually goes like this: fill out a form, get a free trial with ...