Dashboards & Visualizations

How to create a Download Report Button in the Dashboard?

antonio147
Communicator

Hello,
I'm having a hard time creating a download button.
I have a scheduled report every day.
I would like to create a button in the dashbard that downloads that report.
I cannot use js.
Can you help me?
I found a way to download the query created but so I also view the table and I don't want to show it, just download the result.

Tks
Bye
Antonio

Labels (1)
0 Karma
1 Solution

antonio147
Communicator

Below is the code for the button.
I solved
I ask the most skilled if this solution can fit

bye
Antonio

 

<search>
<query>| loadjob savedsearch="antonio:enterprise:Report"
</query>
<done>
<eval token="date">strftime(now(), "%d-%m-%Y")</eval>
<set token="file_name">Report</set>
<set token="sid">$job.sid$</set>
</done>
</search>
<html>
<BR/>
<div style="float: left">
<a href="/api/search/jobs/$sid$/results?isDownload=true&amp;timeFormat=%25FT%25T.%25Q%25%3Az&amp;maxLines=0&amp;count=0&amp;filename=$file_name$_$date$.csv&amp;outputMode=csv" class="button js-button">Download Data</a>
</div>
<style>

 

 

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @antonio147,

I'm not an expert of HTML but I think that it isn't possible without using a JS.

As a workaround, you could use the standard "Export" button present in every panel.

Ciao.

Giuseppe

0 Karma

antonio147
Communicator

Hi Giuseppe,
I managed to create a download button for a table that I showed above without using js.
so :

<row>
<panel>
<table>
<search>
<done>
<eval token="date">strftime(now(), "%d-%m-%Y")</eval>
<set token="file_name">Tabella_Completa</set>
<set token="sid">$job.sid$</set>
</done>

<query>| loadjob savedsearch="antoino:enterprise:AGGREGATO_DATE"
|rename 00_MESE_PRECEDENTE as "MESE_ATTUALE"

</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
<sampleRatio>1</sampleRatio>
</search>
<option name="count">20</option>
<option name="dataOverlayMode">none</option>
<option name="drilldown">none</option>
<option name="percentagesRow">false</option>
<option name="rowNumbers">false</option>
<option name="totalsRow">false</option>
<option name="wrap">true</option>
</table>
<html>

<a href="/api/search/jobs/$sid$/results?isDownload=true&amp;timeFormat=%25FT%25T.%25Q%25%3Az&amp;maxLines=0&amp;count=0&amp;filename=$file_name$_$date$.csv&amp;outputMode=csv" class="button js-button">Estrai Pratiche</a>
<style>
.button {
background-color: steelblue;
border-radius: 5px;
color: white;
padding: .5em;
text-decoration: none;
}

.button:focus,
.button:hover {
background-color: #2A4E6C;
color: White;
}
</style>
</html>
</panel>
</row>


Now my need is to give the possibility to download a report that is in crontab on the Report panel.
I tried to insert it in a table and this is how it works but I can't put the table "hidden".
Also tried with the condition but it doesn't work.
Thanks for your answer
Antonio

0 Karma

antonio147
Communicator

Below is the code for the button.
I solved
I ask the most skilled if this solution can fit

bye
Antonio

 

<search>
<query>| loadjob savedsearch="antonio:enterprise:Report"
</query>
<done>
<eval token="date">strftime(now(), "%d-%m-%Y")</eval>
<set token="file_name">Report</set>
<set token="sid">$job.sid$</set>
</done>
</search>
<html>
<BR/>
<div style="float: left">
<a href="/api/search/jobs/$sid$/results?isDownload=true&amp;timeFormat=%25FT%25T.%25Q%25%3Az&amp;maxLines=0&amp;count=0&amp;filename=$file_name$_$date$.csv&amp;outputMode=csv" class="button js-button">Download Data</a>
</div>
<style>

 

 

0 Karma

splunksumman
Explorer

Hey,

Does anyone know what is the updated code for the v2 endpoint? I am trying to deploy apps with this config to Splunk Cloud but the vetting fails because new version of Splunk doesnt support old endpoint

I tried adapting the line of code for the button with the documentation, but it doesnt download anything and redirects to a 404 page.

0 Karma

DanielPi
Moderator
Moderator

Hi @splunksumman  -

I’m a Community Moderator in the Splunk Community. 
This question was posted 1 year ago, so it might not get the attention you need for your question to be answered. We recommend that you post a new question so that your issue can get the  visibility it deserves. To increase your chances of getting help from the community, follow these guidelines in the Splunk Answers User Manual when creating your post.

Thank you!

0 Karma
Get Updates on the Splunk Community!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...