mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
- Start working on a new web interface. Previous one was merb, new one is
async_sinatra. Initially supporting only ElasticSearch as a backend, will add more eventually. Example: % curl http://localhost:9292/search?q=helloworld {"received_timestamp"=>"2010-10-24 09:59:05.969670Z", "tags"=>["linux-syslog"], "message"=>"...", "source"=>"file://snack.home/var/log/user.log"} <p> {"received_timestamp"=>"2010-10-24 09:59:05.973771Z", "tags"=>["linux-syslog"], "message"=>"...", "source"=>"file://snack.home/var/log/messages"} <p>
This commit is contained in:
parent
b1d2e5e9b1
commit
983ded0aff
2 changed files with 49 additions and 0 deletions
45
web/server.rb
Executable file
45
web/server.rb
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env ruby
|
||||
##rackup -Ilib:../lib -s thin
|
||||
|
||||
require "rubygems"
|
||||
require "json"
|
||||
require "eventmachine"
|
||||
require "em-http-request"
|
||||
require "rack"
|
||||
require "sinatra/async"
|
||||
#require "haml"
|
||||
require "erb"
|
||||
require "ap"
|
||||
|
||||
class EventMachine::ConnectionError < RuntimeError; end
|
||||
|
||||
class LogStashWeb < Sinatra::Base
|
||||
register Sinatra::Async
|
||||
|
||||
aget '/search' do
|
||||
http = EventMachine::HttpRequest.new("http://localhost:9200/_search")
|
||||
esreq = {
|
||||
"query" => {
|
||||
"query_string" => {
|
||||
"query" => params[:q]
|
||||
}
|
||||
}
|
||||
}
|
||||
req = http.get :body => esreq.to_json
|
||||
req.callback do
|
||||
headers req.response_header
|
||||
data = JSON.parse(req.response)
|
||||
@hits = data["hits"]["hits"]
|
||||
body erb :search
|
||||
end
|
||||
req.errback do
|
||||
body "Failed."
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Rack::Handler::Thin.run(
|
||||
Rack::CommonLogger.new( \
|
||||
Rack::ShowExceptions.new( \
|
||||
LogStashWeb.new)),
|
||||
:Port => 9292)
|
4
web/views/search.erb
Normal file
4
web/views/search.erb
Normal file
|
@ -0,0 +1,4 @@
|
|||
<% @hits.each do |hit| %>
|
||||
<%= hit["_source"].inspect %>
|
||||
<p>
|
||||
<% end %>
|
Loading…
Add table
Add a link
Reference in a new issue