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!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...