8
votes

I am exploring Logstash to receive inputs on HTTP. I have installed http plugin using:

plugin install logstash-input-http

The installation was successfull. Then I tried to run logstash using following command:

logstash -e 'input {http {port => 8900}} output {stdout{codec => rubydebug}}'

But logstash terminates without giving any error as such.

Don't know how to verify whether plugin is installed correctly or not. And how to utilize the http plugin to test a sample request.

Thanks in Advance!

2
That config works fine for me on Logstash 2.3.2. Try to launch logstash with the --debug flag then you can see if the HTTP input is being initialized properly. Also run plugin list to see if the http plugin shows up in the list.Val
@Val - Running plugin list shows the http-plugin available. But while launching logstash with --debug option leads to no result, it still terminates without any error. I am using Logstash 2.3.1 version. I tried downloading the 2.3.2 zip version, but I am unable to see the "bin" folder. Are there any structural changes in these two versions.SuperCoder
No, the 2.3.2 release has the same structure as far as I know. Can you update your question with the --debug logs you see? Is it possible that your port 8900 is already bound to some other process?Val

2 Answers

17
votes

I was able to solve the problem by using the .conf file instead of command line arguments.

I created a http-pipeline.conf file similar to below:

input {
 http {
    host => "0.0.0.0"
    port => "8080"
  }
}

output {
    stdout {}
}

And then executed Logstash like:

logstash -f http-pipeline.conf

Using a POSTMAN tool, I sent a POST request(http://localhost:8080) to Logstash with a sample string and voila it appeared on the Logstash console.

2
votes

If you are executing from the same domain following will be sufficient.

input {
    http {
    port => 5043
  }
}
output {
    file {
        path => "/log_streaming/my_app/app.log"
    }
}

If you want to executing a request on a different domain of the website then you need to set few response headers

input {
    http {
    port => 5043
    response_headers => {
      "Access-Control-Allow-Origin" => "*"
      "Content-Type" => "text/plain"
      "Access-Control-Allow-Headers" => "Origin, X-Requested-With, Content-Type, 
       Accept"
    }
  }
}
output {
    file {
       path => "/log_streaming/my_app/app.log"
    }
}