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



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

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

#gcObject



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

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

#hot_threads(options = {}) ⇒ Object



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

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

#jvmObject



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

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

#memoryObject



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

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



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

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

#processObject



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

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, :load_average]]
  )
end