Search code examples
logstashelastic-stacklogstash-groklogstash-configuration

Post data to logstash using http input


im trying to figure out how to post data to Logstash input from my browser using JavaScript.

JavaScript Post in Json format :

 xhr = new XMLHttpRequest();
 var url = "????????????????";
 xhr.open("POST", url, true);
 xhr.setRequestHeader("Content-type", "application/json");
 var data = JSON.stringify({"test" : testdata123});
 xhr.send(data);

What Url should i be posting to if i want logstash to read this data?

Logstash config file :

input {
  tcp {
    port => ?????
  }
}

I am new to this and would like some advice on how to go about doing this.Please help?


Solution

  • The port in the tcp plugin within your input in logstash, conveys the port on which logtash will be running on. So that you can access logstash using that particular port. Make sure you set a port, which isn't being accessed by any other applications within your server.