class Fluent::Plugin::NodeExporterMetricsInput
Public Instance Methods
configure(conf)
click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_node_exporter_metrics.rb, line 71 def configure(conf) super @collectors = [] config = { procfs_path: @procfs_path, sysfs_path: @sysfs_path } @collectors << NodeExporter::CpuMetricsCollector.new(config) if @cpu @collectors << NodeExporter::DiskstatsMetricsCollector.new(config) if @diskstats @collectors << NodeExporter::FilefdMetricsCollector.new(config) if @filefd @collectors << NodeExporter::LoadavgMetricsCollector.new(config) if @loadavg @collectors << NodeExporter::MeminfoMetricsCollector.new(config) if @meminfo @collectors << NodeExporter::NetdevMetricsCollector.new(config) if @netdev @collectors << NodeExporter::StatMetricsCollector.new(config) if @stat @collectors << NodeExporter::TimeMetricsCollector.new(config) if @time @collectors << NodeExporter::UnameMetricsCollector.new(config) if @uname @collectors << NodeExporter::VmstatMetricsCollector.new(config) if @vmstat if Fluent.linux? if @cpufreq @capability = Fluent::Capability.new(:current_process) unless Etc.getpwuid.uid != 0 and @capability.have_capability?(:effective, :dac_read_search) raise ConfigError, "Linux capability CAP_DAC_READ_SEARCH must be enabled" end @collectors << NodeExporter::CpufreqMetricsCollector.new(config) if @cpufreq end elsif Fluent.windows? raise ConfigError, "node_exporter_metrics is not supported" end if @collectors.empty? raise ConfigError, "all collectors are disabled. Enable at least one collector." end end
refresh_watchers()
click to toggle source
# File lib/fluent/plugin/in_node_exporter_metrics.rb, line 111 def refresh_watchers begin serde = CMetrics::Serde.new @collectors.each do |collector| begin collector.run collector.cmetrics.each do |key, cmetric| serde.concat(cmetric) if cmetric end rescue => e $log.error(e.message) end end record = { "cmetrics" => serde.to_msgpack } serde = nil es = OneEventStream.new(Fluent::EventTime.now, record) router.emit_stream(@tag, es) end rescue => e $log.error(e.message) end
shutdown()
click to toggle source
# File lib/fluent/plugin/in_node_exporter_metrics.rb, line 135 def shutdown end
start()
click to toggle source
Calls superclass method
# File lib/fluent/plugin/in_node_exporter_metrics.rb, line 106 def start super timer_execute(:execute_node_exporter_metrics, @scrape_interval, &method(:refresh_watchers)) end