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

#gcObject



86
87
88
# File 'lib/logstash/api/commands/stats.rb', line 86

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

#hot_threads(options = {}) ⇒ Object



90
91
92
# File 'lib/logstash/api/commands/stats.rb', line 90

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



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/logstash/api/commands/stats.rb', line 61

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

#osObject



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

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

#pipeline(pipeline_id = nil) ⇒ Object



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

def pipeline(pipeline_id = nil)
  if pipeline_id.nil?
    pipeline_ids = service.get_shallow(:stats, :pipelines).keys
    pipeline_ids.each_with_object({}) do |pipeline_id, result|
      result[pipeline_id] = plugins_stats_report(pipeline_id)
    end
  else
    { pipeline_id => plugins_stats_report(pipeline_id) }
  end
rescue # failed to find pipeline
  {}
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