Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use logstash plugin - logstash-input-http

Tags:

logstash

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!

like image 714
SuperCoder Avatar asked May 25 '16 10:05

SuperCoder


People also ask

What is http poller?

The HTTP Poller data source in ArcGIS Velocity sends an HTTP request to the specified URL. This ingests data that can be retrieved in a web browser by browsing to the same URL.

How does Logstash work with the Web?

Logstash is a light-weight, open-source, server-side data processing pipeline that allows you to collect data from a variety of sources, transform it on the fly, and send it to your desired destination. It is most often used as a data pipeline for Elasticsearch, an open-source analytics and search engine.

How does Logstash send data to Elasticsearch?

Logstash uses an input plugin to ingest data and an Elasticsearch output plugin to index the data in Elasticsearch, following the Logstash processing pipeline. A Logstash instance has a fixed pipeline constructed at startup, based on the instance's configuration file.


2 Answers

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.

like image 179
SuperCoder Avatar answered Sep 22 '22 06:09

SuperCoder


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"
    }
}
like image 42
Swapnil Avatar answered Sep 22 '22 06:09

Swapnil