Class: LogStash::Api::Commands::Stats
- Inherits:
-
Base
- Object
- Base
- LogStash::Api::Commands::Stats
show all
- Defined in:
- lib/logstash/api/commands/stats.rb
Defined Under Namespace
Modules: PluginsStats
Instance Attribute Summary
Attributes inherited from Base
#service
Instance Method Summary
collapse
Methods inherited from Base
#extract_metrics, #initialize, #started_at, #uptime
Instance Method Details
#events ⇒ Object
56
57
58
59
60
61
|
# File 'lib/logstash/api/commands/stats.rb', line 56
def events
(
[:stats, :events],
:in, :filtered, :out, :duration_in_millis, :queue_push_duration_in_millis
)
end
|
#gc ⇒ Object
111
112
113
|
# File 'lib/logstash/api/commands/stats.rb', line 111
def gc
service.get_shallow(:jvm, :gc)
end
|
#hot_threads(options = {}) ⇒ Object
115
116
117
|
# File 'lib/logstash/api/commands/stats.rb', line 115
def hot_threads(options={})
HotThreadsReport.new(self, options)
end
|
#jvm ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/logstash/api/commands/stats.rb', line 28
def jvm
{
:threads => (
[:jvm, :threads],
:count,
:peak_count
),
:mem => memory,
:gc => gc,
:uptime_in_millis => service.get_shallow(:jvm, :uptime_in_millis),
}
end
|
#memory ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/logstash/api/commands/stats.rb', line 86
def memory
memory = service.get_shallow(:jvm, :memory)
{
:heap_used_percent => memory[:heap][:used_percent],
:heap_committed_in_bytes => memory[:heap][:committed_in_bytes],
:heap_max_in_bytes => memory[:heap][:max_in_bytes],
:heap_used_in_bytes => memory[:heap][:used_in_bytes],
:non_heap_used_in_bytes => memory[:non_heap][:used_in_bytes],
:non_heap_committed_in_bytes => memory[:non_heap][:committed_in_bytes],
:pools => memory[:pools].inject({}) do |acc, (type, hash)|
hash.delete("committed_in_bytes")
acc[type] = hash
acc
end
}
end
|
#os ⇒ Object
103
104
105
106
107
108
109
|
# File 'lib/logstash/api/commands/stats.rb', line 103
def os
service.get_shallow(:os)
rescue
{}
end
|
#pipeline(pipeline_id = nil, opts = {}) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/logstash/api/commands/stats.rb', line 63
def pipeline(pipeline_id = nil, opts={})
extended_stats = LogStash::Config::PipelinesInfo.format_pipelines_info(
service.agent,
service.snapshot.metric_store,
true).each_with_object({}) do |pipeline_stats, memo|
p_id = pipeline_stats["id"].to_s
memo[p_id] = pipeline_stats
end
if pipeline_id.nil?
pipeline_ids = service.get_shallow(:stats, :pipelines).keys
pipeline_ids.each_with_object({}) do |pipeline_id, result|
extended_pipeline = extended_stats[pipeline_id.to_s]
result[pipeline_id] = plugins_stats_report(pipeline_id, extended_pipeline, opts)
end
else
extended_pipeline = extended_stats[pipeline_id.to_s]
{ pipeline_id => plugins_stats_report(pipeline_id, extended_pipeline, opts) }
end
rescue {}
end
|
#process ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/logstash/api/commands/stats.rb', line 45
def process
(
[:jvm, :process],
:open_file_descriptors,
:peak_open_file_descriptors,
:max_file_descriptors,
[:mem, [:total_virtual_in_bytes]],
[:cpu, [:total_in_millis, :percent, :load_average]]
)
end
|
#queue ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/logstash/api/commands/stats.rb', line 14
def queue
pipeline_ids = service.get_shallow(:stats, :pipelines).keys
total_queued_events = 0
pipeline_ids.each do |pipeline_id|
p_stats = service.get_shallow(:stats, :pipelines, pipeline_id.to_sym)
type = p_stats[:queue] && p_stats[:queue][:type].value
pipeline = service.agent.get_pipeline(pipeline_id)
next if pipeline.nil? || pipeline.system? || type != 'persisted'
total_queued_events += p_stats[:queue][:events].value
end
{:events_count => total_queued_events}
end
|
#reloads ⇒ Object
41
42
43
|
# File 'lib/logstash/api/commands/stats.rb', line 41
def reloads
service.get_shallow(:stats, :reloads)
end
|