All Apps and Add-ons

How do you add a Python script to Splunk Enterprise?

mohan401
Engager

Hi All, I am using Splunk Web enterprise. I have created dashboards using UI and I have to do some operation on reports. Can any one please let me know where I have to write Python script and which APP/Add-on I have to plug-in to Splunk Web?
Thanks in Advance..

0 Karma

anjambha
Communicator

Hello Mohan,

You can refer below link..

https://docs.splunk.com/Documentation/Splunk/7.0.0/Admin/Commandsconf

http://dev.splunk.com/view/webframework-tutorials/SP-CAAAERK

Also you can refer below python splunk integration example...

Dashboard source (.xml) :

<dashboard script="refresh_button.js">
<label>Refresh Dashboard</label>
<row>
<panel>
<html>
<button id="refresh" type="button" class="btn" style="float: right;">Refresh
<i class="icon-rotate" style="font-size: 1em;"/>
</button>
</html>
</panel>
</row>
...

Commands.conf :
[refresh]
Filename = refresh.py

Refresh_button.js :
require([
"splunkjs/mvc",
"splunkjs/mvc/searchmanager",
"Jquery",
"splunkjs/mvc/simplexml/ready!"
], function(
mvc,
SearchManager
){
$('#refresh').on("click",function(){
var mySearch = new SearchManager({
id: "mysearch",
preview: true,
cache: true,
search: mvc.tokenSafe("| refresh "),
});
setTimeout("location.reload();", 0);
});
});

refresh.py :
import requests
import json
import csv
...

Get Updates on the Splunk Community!

Dashboards: Hiding charts while search is being executed and other uses for tokens

There are a couple of features of SimpleXML / Classic dashboards that can be used to enhance the user ...

Splunk Observability Cloud's AI Assistant in Action Series: Explaining Metrics and ...

This is the fourth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how ...

Brains, Bytes, and Boston: Learn from the Best at .conf25

When you think of Boston, you might picture colonial charm, world-class universities, or even the crack of a ...