Splunk Search

How to upload file on dashboard, without navigating to another page?

sarvesh_11
Communicator

Hi Splunkers,
I have a use case to deploy, please refer the image attached.
On clicking "choose file" it should browse from the local machine.
On clicking upload it shall store the uploaded file on lookups directory of specific app.
On Submit button we have a SPL query that will merge the lookup, also in merging the lookup, i have to use the name of the uploaded file, which has to be dynamic
alt text

0 Karma

manjunathmeti
SplunkTrust
SplunkTrust

Hi @sarvesh_11 

You can launch inbuilt upload lookup file page from the dashboard. User will upload the CSV file and come back to the dashboard and provide the CSV file name which will be used in your search. Try this.

<form>
  <label>Upload Lookup File</label>
  <fieldset submitButton="false"></fieldset>
  <row>
    <html>
        <a href="/manager/$env:app$/data/lookup-table-files/_new?action=edit" target="_blank">Upload Lookup File</a>
        <p> Click on above link to upload a CSV lookup file and save. Come back to this page and provide <b>Destination filename</b> in text below input.</p>
      </html>
  </row>
  <row>
    <panel>
      <input type="text" token="file_name" searchWhenChanged="true">
        <label>CSV Lookup File Name (Suffix with ".csv")</label>
      </input>
    </panel>
  </row>
  <row>
    <panel>
      <event>
        <search>
          <query>index="_internal" | lookup $file_name$ field as event_field OUTPUT output_field</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="list.drilldown">none</option>
      </event>
    </panel>
  </row>
</form>

 ---

If this reply helps you, an upvote/like would be appreciated.

sarvesh_11
Communicator

@manjunathmeti 

we did exactly the same what you mentioned.

0 Karma

gaurav_maniar
Builder

Hi @sarvesh_11 

Did you find any workaround to upload the file to Splunk server via dashboard??

0 Karma

jkat54
SplunkTrust
SplunkTrust

You need to write JavaScript and python for this.

Frankly, it's not easy.

You could extend the rest api to create a file upload endpoint that does most of the logic.

The endpoint would be coded so that it accepts file of csv format and puts it in the correct app.

The JavaScript would be coded so that it uploads the file to the endpoint while staying on the same page.

The last time I wrote JS to handle a file upload I followed tutorials like this one: https://www.w3schools.com/jsref/prop_fileupload_files.asp

Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

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, ...