Splunk Dev

How to customize a button in the dashboard to run a python script using SplunkJS?

xuehui
New Member

In my dashboard, I want to create a button that runs a python script when it's clicked.

Can I achieve this using SplunkJS?

Labels (2)
Tags (2)
0 Karma

shaskell_splunk
Splunk Employee
Splunk Employee

Splunkjs is Javascript library and it runs in the browser on the client. Python, on the other hand, is an interpreted language that runs server side and isn't exposed via the UI. What does your Python script do? Is there any reason what you're trying to accomplish in Python can't be done purely in Javascript?

It would be helpful to understand what you're trying to do when the button is clicked to suggest a possible solution.

0 Karma

xuehui
New Member

The python script is an API of other program.
I need call this API when click a button to make that program do something.
And, To run the API need some classlib, I think in javascript to call this API is impossible,or troublesome.
Thank you.

0 Karma

shaskell_splunk
Splunk Employee
Splunk Employee

Do you need to use the results of a search to send to an API for validation? I'm still not understanding what exactly you're trying to accomplish and what the workflow is. If so, you could probably handle this with a custom search command.

You can absolutely use Javascript to call an API. The bigger question is if you need to use credentials to authenticate with the API. It also sounds like you're not familiar with coding in Javascript so that's going to be the biggest barrier. To call a REST API in javascript, look at jQuery's ajax.

https://api.jquery.com/jquery.ajax/

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...