Class: LogStash::Inputs::Metrics
- Defined in:
- lib/logstash/inputs/metrics.rb
Overview
The Metrics inputs is responable of registring itself to the collector. The collector class will periodically emits new snapshot of the system, The metrics need to take that information and transform it into a ‘Logstash::Event`, which can be consumed by the shipper and send to Elasticsearch
Constant Summary
Constants included from Config::Mixin
Config::Mixin::ENV_PLACEHOLDER_REGEX, Config::Mixin::PLUGIN_VERSION_0_9_0, Config::Mixin::PLUGIN_VERSION_1_0_0
Constants inherited from Plugin
Instance Attribute Summary
Attributes inherited from Base
Attributes included from Config::Mixin
Attributes inherited from Plugin
Instance Method Summary collapse
Methods inherited from Base
#do_stop, #initialize, plugin_type, #stop?, #tag
Methods included from Config::Mixin
#config_init, included, #replace_env_placeholders
Methods included from Util::Loggable
Methods inherited from Plugin
#close, #config_name, #debug_info, declare_plugin, #do_close, #eql?, #hash, #id, #initialize, #inspect, lookup, #metric, #metric=, #to_s
Constructor Details
This class inherits a constructor from LogStash::Inputs::Base
Instance Method Details
#register ⇒ Object
16 17 |
# File 'lib/logstash/inputs/metrics.rb', line 16 def register end |
#run(queue) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/logstash/inputs/metrics.rb', line 19 def run(queue) @logger.debug("Metric: input started") @queue = queue # we register to the collector after receiving the pipeline queue metric.collector.add_observer(self) # Keep this plugin thread alive, # until we shutdown the metric pipeline sleep(1) while !stop? end |
#stop ⇒ Object
31 32 33 34 |
# File 'lib/logstash/inputs/metrics.rb', line 31 def stop @logger.debug("Metrics input: stopped") metric.collector.delete_observer(self) end |
#update(snapshot) ⇒ Object
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/logstash/inputs/metrics.rb', line 36 def update(snapshot) @logger.debug("Metrics input: received a new snapshot", :created_at => snapshot.created_at, :snapshot => snapshot, :event => snapshot.metric_store.to_event) if @logger.debug? # The back pressure is handled in the collector's # scheduled task (running into his own thread) if something append to one of the listener it will # will timeout. In a sane pipeline, with a low traffic of events it shouldn't be a problems. snapshot.metric_store.each do |metric| @queue << LogStash::Event.new({ "@timestamp" => snapshot.created_at }.merge(metric.to_hash)) end end |