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!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...