Class: Fluent::Plugin::NodeExporterMetricsInput
- Inherits:
-
Input
- Object
- Input
- Fluent::Plugin::NodeExporterMetricsInput
- Defined in:
- lib/fluent/plugin/in_node_exporter_metrics.rb
Instance Method Summary collapse
Instance Method Details
#configure(conf) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# 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 ⇒ Object
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# 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.) 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.) end |
#shutdown ⇒ Object
135 136 |
# File 'lib/fluent/plugin/in_node_exporter_metrics.rb', line 135 def shutdown end |
#start ⇒ Object
106 107 108 109 |
# 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 |