mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
- Add elasticsearch indexing
This commit is contained in:
parent
46c676e7dc
commit
b1d2e5e9b1
1 changed files with 26 additions and 0 deletions
26
lib/logstash/outputs/elasticsearch.rb
Normal file
26
lib/logstash/outputs/elasticsearch.rb
Normal file
|
@ -0,0 +1,26 @@
|
|||
require "logstash/namespace"
|
||||
require "logstash/event"
|
||||
require "uri"
|
||||
require "em-http-request"
|
||||
|
||||
class LogStash::Outputs::Elasticsearch
|
||||
def initialize(url, config={}, &block)
|
||||
@url = url
|
||||
@url = URI.parse(url) if url.is_a? String
|
||||
@config = config
|
||||
end
|
||||
|
||||
def register
|
||||
# Port?
|
||||
# Authentication?
|
||||
@httpurl = @url.clone
|
||||
@httpurl.scheme = "http"
|
||||
end # def register
|
||||
|
||||
def receive(event)
|
||||
http = EventMachine::HttpRequest.new(@httpurl.to_s).post :body => event.to_json
|
||||
http.errback do
|
||||
$stderr.puts "Request to index to #{url.to_s} failed. Event was #{event.to_s}"
|
||||
end
|
||||
end # def event
|
||||
end # class LogStash::Outputs::Websocket
|
Loading…
Add table
Add a link
Reference in a new issue