Class: LogStash::Api::Commands::Stats

Inherits:
Base
  • Object
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

Constructor Details

This class inherits a constructor from LogStash::Api::Commands::Base

Instance Method Details

#eventsObject



33
34
35
36
37
38
# File 'lib/logstash/api/commands/stats.rb', line 33

def events
  extract_metrics(
    [:stats, :events],
    :in, :filtered, :out, :duration_in_millis
  )
end

#gcObject



63
64
65
# File 'lib/logstash/api/commands/stats.rb', line 63

def gc
  service.get_shallow(:jvm, :gc)
end

#hot_threads(options = {}) ⇒ Object



67
68
69
# File 'lib/logstash/api/commands/stats.rb', line 67

def hot_threads(options={})
  HotThreadsReport.new(self, options)
end

#jvmObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/logstash/api/commands/stats.rb', line 10

def jvm
  {
    :threads => extract_metrics(
      [:jvm, :threads],
      :count,
      :peak_count
    ),
    :mem => memory,
    :gc => gc
  }
end

#memoryObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/logstash/api/commands/stats.rb', line 45

def memory
  memory = service.get_shallow(:jvm, :memory)
  {
    :heap_used_in_bytes => memory[:heap][:used_in_bytes],
    :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

#pipelineObject



40
41
42
43
# File 'lib/logstash/api/commands/stats.rb', line 40

def pipeline
  stats = service.get_shallow(:stats, :pipelines)
  PluginsStats.report(stats)
end

#processObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/logstash/api/commands/stats.rb', line 22

def process
  extract_metrics(
    [:jvm, :process],
    :open_file_descriptors,
    :peak_open_file_descriptors,
    :max_file_descriptors,
    [:mem, [:total_virtual_in_bytes]],
    [:cpu, [:total_in_millis, :percent]]
  )
end