mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
- Add error bubbling. Search problems now display to the user.
This commit is contained in:
parent
6714ab1036
commit
daefbe986d
4 changed files with 18 additions and 3 deletions
|
@ -75,7 +75,7 @@ class LogStash::Web::ElasticSearch
|
|||
end
|
||||
req.errback do
|
||||
@logger.warn(["Query failed", params, req.response])
|
||||
yield :failure
|
||||
yield({ "error" => req.response })
|
||||
end
|
||||
end # def search
|
||||
end
|
||||
|
|
|
@ -49,11 +49,21 @@ class LogStash::Web::Server < Sinatra::Base
|
|||
count = params["count"] = (params["count"] or 50).to_i
|
||||
offset = params["offset"] = (params["offset"] or 0).to_i
|
||||
elasticsearch.search(params) do |@results|
|
||||
#p instance_variables
|
||||
if @results.include?("error")
|
||||
body haml :"search/error", :layout => !request.xhr?
|
||||
next
|
||||
end
|
||||
|
||||
@hits = (@results["hits"]["hits"] rescue [])
|
||||
@total = (@results["hits"]["total"] rescue 0)
|
||||
@graphpoints = []
|
||||
@results["facets"]["by_hour"]["entries"].each do |entry|
|
||||
@graphpoints << [entry["key"], entry["count"]]
|
||||
begin
|
||||
@results["facets"]["by_hour"]["entries"].each do |entry|
|
||||
@graphpoints << [entry["key"], entry["count"]]
|
||||
end
|
||||
rescue => e
|
||||
puts e
|
||||
end
|
||||
|
||||
if count and offset
|
||||
|
|
3
lib/logstash/web/views/search/error.haml
Normal file
3
lib/logstash/web/views/search/error.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
#error
|
||||
%h4 The query '#{params["q"]}' resulted the following error:
|
||||
%pre&= @results["error"]
|
|
@ -46,6 +46,8 @@ body
|
|||
background-color: pink
|
||||
border: 1px solid red
|
||||
padding: 3px
|
||||
pre
|
||||
white-space: pre-wrap
|
||||
#error h1
|
||||
font-size: 130%
|
||||
padding: 0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue