Getting Data In

How to write to CSV file in splunk without using a search manager

theoborrero
Explorer

Hi ,

We have created a splunk application using HTML format. In our application we have a "Request Alert" button that has a popup which takes user input text fields then writes out to a csv file . The code we are using for this works fine for taking the input field and storing them in a csv file in the local computer. The file location path( we give it works just fine if it is in our local computer , but once we give it the path to where splunk stores all the other csv files that are created , it does not ever work.

Is it possible to write to a csv file in splunk without using a search manager ? I have an example of the code we are using listed below.

   <script>

              function closePopup(){
                document.getElementById('light').style.display='none';
                document.getElementById('fade').style.display='none';
              }
                //Save alert details in CSV file

              function writeToFile(d1, d2, d3, d4, d5){
              var fso = new ActiveXObject("Scripting.FileSystemObject");
              var fileLoc = "C:\\Users\\plm3030\\Desktop\\Splunk Docs\\sample.csv";
              var fh = fso.OpenTextFile(fileLoc, 8, false, 0);

              fh.WriteLine(d1 + ',' + d2 + ',' + d3 +',' + d4+',' + d5);
              fh.Close();
              closePopup();
              alert("Your alert submitted successfully!");
              }
              var submitAlert = document.getElementById("submitAlert");
              submitAlert.onclick = function () {
              var queryVal      = document.getElementById("queryVal").value;
              var poc = document.getElementById("poc").value
              var email = document.getElementById("emailGroup").value;
              var alertName = document.getElementById("alertName").value;
              var details = document.getElementById("details").value;
              writeToFile(queryVal, poc, email, alertName, details);
              }
                //End Alert Details to CSV
            </script>
Tags (1)
0 Karma

woodcock
Esteemed Legend

Check out this app (either use it or figure out how it does it):

https://splunkbase.splunk.com/app/1724/

0 Karma

Yasaswy
Contributor

Hi,
If you are looking for an "out of splunk" solution... you will need some server side scripting. You can use XMLHttpRequest Object in your client script. Check out the basic tutorial here..

0 Karma
Get Updates on the Splunk Community!

Splunk Observability Cloud’s AI Assistant in Action Series: Analyzing and ...

This is the second post in our Splunk Observability Cloud’s AI Assistant in Action series, in which we look at ...

Elevate Your Organization with Splunk’s Next Platform Evolution

 Thursday, July 10, 2025  |  11AM PDT / 2PM EDT Whether you're managing complex deployments or looking to ...

Splunk Answers Content Calendar, June Edition

Get ready for this week’s post dedicated to Splunk Dashboards! We're celebrating the power of community by ...