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!

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer at Splunk .conf24 ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

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

Combine Multiline Logs into a Single Event with SOCK: a Step-by-Step Guide for ...

Combine multiline logs into a single event with SOCK - a step-by-step guide for newbies Olga Malita The ...