mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
parent
77294b9f5a
commit
e78fce609b
5 changed files with 19 additions and 6 deletions
|
@ -8,8 +8,6 @@ module LogStash
|
|||
module Commands
|
||||
class Stats < Commands::Base
|
||||
def jvm
|
||||
require "pry"
|
||||
binding.pry
|
||||
{
|
||||
:threads => extract_metrics(
|
||||
[:jvm, :threads],
|
||||
|
|
|
@ -101,7 +101,7 @@ module LogStash module Instrument module PeriodicPoller
|
|||
|
||||
def collect_jvm_metrics(data)
|
||||
runtime_mx_bean = ManagementFactory.getRuntimeMXBean()
|
||||
metric.gauge(:jvm, :uptime_in_millis, runtime_mx_bean.getUptime())
|
||||
metric.gauge([:jvm], :uptime_in_millis, runtime_mx_bean.getUptime())
|
||||
collect_heap_metrics(data)
|
||||
collect_non_heap_metrics(data)
|
||||
end
|
||||
|
|
|
@ -14,6 +14,7 @@ describe LogStash::Api::Modules::NodeStats do
|
|||
# DSL describing response structure
|
||||
root_structure = {
|
||||
"jvm"=>{
|
||||
"uptime_in_millis" => Numeric,
|
||||
"threads"=>{
|
||||
"count"=>Numeric,
|
||||
"peak_count"=>Numeric
|
||||
|
|
|
@ -5,9 +5,7 @@ require "json"
|
|||
class MonitoringAPI
|
||||
|
||||
def pipeline_stats
|
||||
resp = Manticore.get("http://localhost:9600/_node/stats/pipeline").body
|
||||
stats_response = JSON.parse(resp)
|
||||
stats_response["pipeline"]
|
||||
node_stats["pipeline"]
|
||||
end
|
||||
|
||||
def event_stats
|
||||
|
@ -27,4 +25,9 @@ class MonitoringAPI
|
|||
JSON.parse(resp)
|
||||
end
|
||||
|
||||
def node_stats
|
||||
resp = Manticore.get("http://localhost:9600/_node/stats").body
|
||||
JSON.parse(resp)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -32,4 +32,15 @@ describe "Test Monitoring API" do
|
|||
end
|
||||
end
|
||||
|
||||
it "can retrieve JVM stats" do
|
||||
logstash_service = @fixture.get_service("logstash")
|
||||
logstash_service.start_with_stdin
|
||||
logstash_service.wait_for_logstash
|
||||
|
||||
Stud.try(max_retry.times, RSpec::Expectations::ExpectationNotMetError) do
|
||||
result = logstash_service.monitoring_api.node_stats
|
||||
expect(result["jvm"]["uptime_in_millis"]).to be > 100
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue