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
Get Updates on the Splunk Community!

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Get Inspired! We’ve Got Validation that Your Hard Work is Paying Off

We love our Splunk Community and want you to feel inspired by all your hard work! Eric Fusilero, our VP of ...

What's New in Splunk Enterprise 9.4: Features to Power Your Digital Resilience

Hey Splunky People! We are excited to share the latest updates in Splunk Enterprise 9.4. In this release we ...