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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...