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!

Updated Data Type Articles, Anniversary Celebrations, and More on Splunk Lantern

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

A Prelude to .conf25: Your Guide to Splunk University

Heading to Boston this September for .conf25? Get a jumpstart by arriving a few days early for Splunk ...

4 Ways the Splunk Community Helps You Prepare for .conf25

.conf25 is right around the corner, and whether you’re a first-time attendee or a seasoned Splunker, the ...