mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 22:57:16 -04:00
parent
702e69cd6b
commit
a90f56a39c
3 changed files with 35 additions and 12 deletions
|
@ -11,13 +11,19 @@ module LogStash
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/hot_threads" do
|
get "/hot_threads" do
|
||||||
ignore_idle_threads = params["ignore_idle_threads"] || true
|
begin
|
||||||
|
ignore_idle_threads = params["ignore_idle_threads"] || true
|
||||||
|
|
||||||
options = { :ignore_idle_threads => as_boolean(ignore_idle_threads) }
|
options = {:ignore_idle_threads => as_boolean(ignore_idle_threads)}
|
||||||
options[:threads] = params["threads"].to_i if params.has_key?("threads")
|
options[:threads] = params["threads"].to_i if params.has_key?("threads")
|
||||||
|
|
||||||
as = human? ? :string : :json
|
as = human? ? :string : :json
|
||||||
respond_with(node.hot_threads(options), {:as => as})
|
respond_with(node.hot_threads(options), {:as => as})
|
||||||
|
rescue ArgumentError => e
|
||||||
|
response = respond_with({"error" => e.message})
|
||||||
|
status(400)
|
||||||
|
response
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/pipelines/:id" do
|
get "/pipelines/:id" do
|
||||||
|
|
|
@ -9,14 +9,20 @@ module LogStash
|
||||||
|
|
||||||
# return hot threads information
|
# return hot threads information
|
||||||
get "/jvm/hot_threads" do
|
get "/jvm/hot_threads" do
|
||||||
top_threads_count = params["threads"] || 3
|
begin
|
||||||
ignore_idle_threads = params["ignore_idle_threads"] || true
|
top_threads_count = params["threads"] || 3
|
||||||
options = {
|
ignore_idle_threads = params["ignore_idle_threads"] || true
|
||||||
:threads => top_threads_count.to_i,
|
options = {
|
||||||
:ignore_idle_threads => as_boolean(ignore_idle_threads)
|
:threads => top_threads_count.to_i,
|
||||||
}
|
:ignore_idle_threads => as_boolean(ignore_idle_threads)
|
||||||
|
}
|
||||||
|
|
||||||
respond_with(stats_command.hot_threads(options))
|
respond_with(stats_command.hot_threads(options))
|
||||||
|
rescue ArgumentError => e
|
||||||
|
response = respond_with({"error" => e.message})
|
||||||
|
status(400)
|
||||||
|
response
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# return hot threads information
|
# return hot threads information
|
||||||
|
|
|
@ -46,6 +46,17 @@ describe LogStash::Api::Modules::Node do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "broken params in URL" do
|
||||||
|
|
||||||
|
before(:all) do
|
||||||
|
get "/hot_threads?human=?threads=5"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return http status 400" do
|
||||||
|
expect(last_response.status).to eq(400)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "when asking for human output" do
|
context "when asking for human output" do
|
||||||
[
|
[
|
||||||
"/hot_threads?human",
|
"/hot_threads?human",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue