Class: Fluent::Plugin::SplunkHecOutput
- Inherits:
-
SplunkOutput
- Object
- Output
- SplunkOutput
- Fluent::Plugin::SplunkHecOutput
- Defined in:
- lib/fluent/plugin/out_splunk_hec.rb
Constant Summary collapse
- KEY_FIELDS =
%w[index time host source sourcetype metric_name metric_value].freeze
- TAG_PLACEHOLDER =
'${tag}'.freeze
- MISSING_FIELD =
Hash.new do |_h, k| $log.warn "expected field #{k} but it's missing" if defined?($log) MISSING_FIELD end.freeze
Instance Method Summary collapse
- #configure(conf) ⇒ Object
- #format(tag, time, record) ⇒ Object
-
#initialize ⇒ SplunkHecOutput
constructor
A new instance of SplunkHecOutput.
- #multi_workers_ready? ⇒ Boolean
- #shutdown ⇒ Object
- #start ⇒ Object
- #write(chunk) ⇒ Object
Constructor Details
#initialize ⇒ SplunkHecOutput
Returns a new instance of SplunkHecOutput.
140 141 142 143 144 |
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 140 def initialize super @default_host = Socket.gethostname @extra_fields = nil end |
Instance Method Details
#configure(conf) ⇒ Object
146 147 148 149 150 151 |
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 146 def configure(conf) super raise Fluent::ConfigError, 'One of `hec_host` or `full_url` is required.' if @hec_host.empty? && @full_url.empty? check_metric_configs pick_custom_format_method end |
#format(tag, time, record) ⇒ Object
185 186 187 |
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 185 def format(tag, time, record) # this method will be replaced in `configure` end |
#multi_workers_ready? ⇒ Boolean
189 190 191 |
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 189 def multi_workers_ready? true end |
#shutdown ⇒ Object
180 181 182 183 |
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 180 def shutdown @conn.shutdown if not @conn.nil? super end |
#start ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 157 def start super @conn = Net::HTTP::Persistent.new.tap do |c| c.verify_mode = @insecure_ssl ? OpenSSL::SSL::VERIFY_NONE : OpenSSL::SSL::VERIFY_PEER c.cert = OpenSSL::X509::Certificate.new File.read(@client_cert) if @client_cert c.key = OpenSSL::PKey::RSA.new File.read(@client_key) if @client_key c.ca_file = @ca_file c.ca_path = @ca_path c.ciphers = @ssl_ciphers c.proxy = :ENV c.min_version = OpenSSL::SSL::TLS1_1_VERSION if @require_ssl_min_version c.override_headers['Content-Type'] = 'application/json' c.override_headers['User-Agent'] = "fluent-plugin-splunk_hec_out/#{VERSION}" c.override_headers['Authorization'] = "Splunk #{@hec_token}" c.override_headers['__splunk_app_name'] = "#{@app_name}" c.override_headers['__splunk_app_version'] = "#{@app_version}" @custom_headers.each do |header, value| c.override_headers[header] = value end end end |
#write(chunk) ⇒ Object
153 154 155 |
# File 'lib/fluent/plugin/out_splunk_hec.rb', line 153 def write(chunk) super end |