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



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

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

#gcObject



79
80
81
# File 'lib/logstash/api/commands/stats.rb', line 79

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

#hot_threads(options = {}) ⇒ Object



83
84
85
# File 'lib/logstash/api/commands/stats.rb', line 83

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

#jvmObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/logstash/api/commands/stats.rb', line 13

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



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/logstash/api/commands/stats.rb', line 53

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

#osObject



71
72
73
74
75
76
77
# File 'lib/logstash/api/commands/stats.rb', line 71

def os
  service.get_shallow(:os)
rescue
  # The only currently fetch OS information is about the linux
  # containers.
  {}
end

#pipelineObject



48
49
50
51
# File 'lib/logstash/api/commands/stats.rb', line 48

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

#processObject



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

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

#reloadsObject



26
27
28
# File 'lib/logstash/api/commands/stats.rb', line 26

def reloads
  service.get_shallow(:stats, :reloads)
end