Class: Fluent::Plugin::SplunkHecOutput
- Inherits:
-
Output
- Object
- Output
- Fluent::Plugin::SplunkHecOutput
- Defined in:
- lib/fluent/plugin/out_splunk_hec.rb
Constant Summary collapse
- KEY_FIELDS =
%w[index host source sourcetype metric_name metric_value].freeze
- TAG_PLACEHOLDER =
'${tag}'.freeze
- MISSING_FIELD =
Hash.new { |h, k| $log.warn "expected field #{k} but it's missing" if defined?($log) MISSING_FIELD }.freeze
Instance Method Summary collapse
- #close ⇒ Object
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ SplunkHecOutput
constructor
A new instance of SplunkHecOutput.
- #multi_workers_ready? ⇒ Boolean
- #start ⇒ Object
- #try_write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ SplunkHecOutput
Returns a new instance of SplunkHecOutput.
121 122 123 124 125 126 |
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 121 def initialize super @default_host = Socket.gethostname @chunk_queue = SizedQueue.new 1 @extra_fields = nil end |
Instance Method Details
#close ⇒ Object
158 159 160 161 |
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 158 def close @chunk_queue.close super end |
#configure(conf) ⇒ Object
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 128 def configure(conf) super check_conflict check_metric_configs construct_api prepare_key_fields configure_fields(conf) pick_custom_format_method # @formatter_configs is from formatter helper @formatters = @formatter_configs.map { |section| MatchFormatter.new section.usage, formatter_create(usage: section.usage) } end |
#format(tag, time, record) ⇒ Object
149 150 151 |
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 149 def format(tag, time, record) # this method will be replaced in `configure` end |
#multi_workers_ready? ⇒ Boolean
163 164 165 |
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 163 def multi_workers_ready? true end |
#start ⇒ Object
144 145 146 147 |
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 144 def start super start_worker_threads end |
#try_write(chunk) ⇒ Object
153 154 155 156 |
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 153 def try_write(chunk) log.debug { "Received new chunk, size=#{chunk.read.bytesize}" } @chunk_queue << chunk end |