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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...