Module: LogStash::Api::Commands::Stats::PluginsStats

Defined in:
lib/logstash/api/commands/stats.rb

Class Method Summary collapse

Class Method Details

.plugin_stats(stats, plugin_type) ⇒ Object



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

def plugin_stats(stats, plugin_type)
  # Turn the `plugins` stats hash into an array of [ {}, {}, ... ]
  # This is to produce an array of data points, one point for each
  # plugin instance.
  return [] unless stats[:plugins] && stats[:plugins].include?(plugin_type)
  stats[:plugins][plugin_type].collect do |id, data|
    { :id => id }.merge(data)
  end
end

.report(stats) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/logstash/api/commands/stats.rb', line 85

def report(stats)
  # Only one pipeline right now.
  stats = stats[:main]

  {
    :events => stats[:events],
    :plugins => {
      :inputs => plugin_stats(stats, :inputs),
      :filters => plugin_stats(stats, :filters),
      :outputs => plugin_stats(stats, :outputs)
    },
    :reloads => stats[:reloads],
  }
end