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
SplunkTrust
SplunkTrust

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!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...