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!

Dashboards: Hiding charts while search is being executed and other uses for tokens

There are a couple of features of SimpleXML / Classic dashboards that can be used to enhance the user ...

Splunk Observability Cloud's AI Assistant in Action Series: Explaining Metrics and ...

This is the fourth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how ...

Brains, Bytes, and Boston: Learn from the Best at .conf25

When you think of Boston, you might picture colonial charm, world-class universities, or even the crack of a ...