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!

Improve Data Pipelines Using Splunk Data Management

  Register Now   This Tech Talk will explore the pipeline management offerings Edge Processor and Ingest ...

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud?

Register Join this Tech Talk to learn how unique features like Service Centric Views, Tag Spotlight, and ...

Thank You for Celebrating CX Day with Splunk!

Yesterday the entire team at Splunk &#43; Cisco joined the global celebration of CX Day - celebrating our ...