Dashboards & Visualizations

can we pass token values from a dashboard as parameters to python script being used as a data input ?

aayushisplunk1
Path Finder

i have added an input as a drop down in a dashboard. I want to use the token value for the selected item from the drop down to be passed a parameter to a python script , which i have added as a local script from the "Add Inputs" option.
Is it possible to pass tokens as parameters to the python script (being used as a data input) ?
If yes, how can we do that ?

Tags (1)
0 Karma

DavidHourani
Super Champion

Hi @aayushisplunk1,

There is no clean way to do this, but it can be done as follows.

First of all you will need to define a custom search command that allows you to modify the specific script under bin in your app with the token parameter. Let's call this command "passValue" and make it take one parameter. So to call your script you would call it like this : | passValue value
See here for creating custom search commands :http://dev.splunk.com/view/SP-CAAAFFT

Once you got that custom command ready. You can easily make the dashboard you mentioned in your question using this logic :

1- User selects token.
2- User hits submit.
3- One of the panels contains the | passValue $value$ command with the token. So once the submit button is hit, the script will do it's charm and modify your scripted inputs.
4- Next time the scripted inputs run, it will use the new script with the modified value from the token.

Cheers,
David

0 Karma
Get Updates on the Splunk Community!

Detecting Remote Code Executions With the Splunk Threat Research Team

REGISTER NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If ...

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...