Getting Data In

[RESOLVED] Is there a way to modify input script arguments through a setup screen (setup.xml)?

Estrellia
Explorer

Hello all,

I read some docs about how to set up a screen to allow my user to customize the inputs.conf of the application I created.

However, I can't find an answer to this question: Is there a way to change the arguments of the input script through this setup screen?

Let me explain it:

[script://$SPLUNK_HOME/etc/apps/myAppFolder/bin/scripts/myScript.sh CREDENTIALS IP_TO_REACH PORT]

Where of course credentials Ip_to_reach and Port are placeholders and need to be replaced once the app has been configured.

I would like my user to be able to modify this line to replace the credentials, Ip and port.

I read on the documentation the possibility to change the "fields" in each input but in this particular case I can't seem to find the way... I can only create a new object.
But there is nothing on how to modify it.

Thanks for your help guys, I'm a beginner so I apologize if it's an easy question.

Cheers

0 Karma
1 Solution

jconger
Splunk Employee
Splunk Employee

The "correct" way to handle situations like this is to create a modular input. Modular inputs allow you to specify parameters with a user interface. There was a great session on this at the 2015 .conf
Recording -> http://conf.splunk.com/session/2015/recordings/2015-splunk-71.mp4
Slides -> http://conf.splunk.com/session/2015/conf2015_SHaskell_Splunk_Developing_ModularInputsIfYou.pdf

In the case of setup.xml, the text between the brackets is your entity. The default setup handlers can modify fields for an entity, but you would need to use a custom setup handler to create/delete entities if you wanted to stick with a scripted input with command line parameters.

View solution in original post

jconger
Splunk Employee
Splunk Employee

The "correct" way to handle situations like this is to create a modular input. Modular inputs allow you to specify parameters with a user interface. There was a great session on this at the 2015 .conf
Recording -> http://conf.splunk.com/session/2015/recordings/2015-splunk-71.mp4
Slides -> http://conf.splunk.com/session/2015/conf2015_SHaskell_Splunk_Developing_ModularInputsIfYou.pdf

In the case of setup.xml, the text between the brackets is your entity. The default setup handlers can modify fields for an entity, but you would need to use a custom setup handler to create/delete entities if you wanted to stick with a scripted input with command line parameters.

Estrellia
Explorer

Hello,

Thank you for your help, it is indeed what I was looking for!

Cheers

0 Karma

Masa
Splunk Employee
Splunk Employee

If I were you, I would use Modular Input instead of scripted input in case I would like to have user input for custom parameters to pass to my Modular Input script. By making use of Modular Input feature, add option to let user define value for custom attribute through Settings -> Data Inputs -> Name of your custom Modular Input
(ref. http://docs.splunk.com/Documentation/Splunk/6.4.2/AdvancedDev/ModInputsIntro#Comparing_modular_input... )

Useful doc links for Modular Inputs are
https://docs.splunk.com/Documentation/Splunk/6.4.2/AdvancedDev/ModInputsBasicExample
http://dev.splunk.com/view/python-sdk/SP-CAAAER3

Estrellia
Explorer

Hello,

Thanks for your reply, I'll dig this way.

Cheers

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...