Dashboards & Visualizations

How to create a button for dashboard that exports CSV of specific panel

anasbk
Explorer

Hi,
I want to create a button that exports the result of a specific panel in csv format.
I created the button using the tag as the image shown below.

alt text

I tried to inspect the javascript code of export button provided by Splunk but it seems complicated
I'm sure there is a better way to do that.

Thanks in advance !

0 Karma

anasbk
Explorer

I wanted to customize the button, found solution here:
https://answers.splunk.com/answers/755018/export-to-csv-on-click-of-button.html

starcher
Influencer

You can also just click the little download icon in the popup as you mouse over the panel. It is shown in your screen shot. Next to the search magnifier icon. Bottom right.

0 Karma

anasbk
Explorer

i wanted to make a custom search, not the button provided by Splunk

0 Karma

anasbk
Explorer

I tried to inspect the javascript export button provided by Splunk and found the code that creates the ExportResultDialog in path /opt/splunk/share/splunk/search_mrsparkle/exposed/js/views/dashboard/element/Footer.js

this object is responsible for showing the export Modal and initializing the object.

I created this javascript code but it seems it has a lot of dependencies and js errors

require([
     'splunkjs/mvc',
     'views/shared/jobstatus/buttons/ExportResultsDialog'

 ], function(mvc , ExportResultsDialog) {



    var btn = $('.toto')
    _export = function () {
      console.log(this)

         /* var sid = this.manager.getSid();
          console.log(sid)
          */
          //this.searchJobModel.set("id", sid);
        var exportDialog = new ExportResultsDialog({
            model: {
                //searchJob: this.searchJobModel,
                //application: this.model.application,
                //report: this.model.report
            },
            usePanelType: true,
            onHiddenRemove: true
        });

        exportDialog.render().appendTo($("body"));
        exportDialog.show();

     }

     btn.click( function () {_export()})



 });
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...