Class: LogStash::Inputs::Logstash
- Inherits:
-
Base
- Object
- Base
- LogStash::Inputs::Logstash
- Includes:
- PluginMixins::PluginFactorySupport
- Defined in:
- lib/logstash/inputs/logstash.rb
Defined Under Namespace
Classes: QueueWrapper
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(*a) ⇒ Logstash
constructor
A new instance of Logstash.
- #inner_http_input_options ⇒ Object
- #inner_json_lines_codec_options ⇒ Object
- #register ⇒ Object
- #report_invalid_config!(message) ⇒ Object
- #run(queue) ⇒ Object
- #ssl_identity_options ⇒ Object
- #ssl_trust_options ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(*a) ⇒ Logstash
Returns a new instance of Logstash.
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/logstash/inputs/logstash.rb', line 44 def initialize(*a) super if original_params.include?('codec') report_invalid_config! 'The `logstash` input does not have an externally-configurable `codec`' end logger.debug("initializing inner HTTP input plugin") @internal_http = plugin_factory.input('http').new() logger.debug("inner HTTP input plugin has been initialized") end |
Instance Method Details
#close ⇒ Object
77 78 79 80 81 |
# File 'lib/logstash/inputs/logstash.rb', line 77 def close logger.debug("closing inner HTTP input plugin") @internal_http.close logger.debug('inner HTTP plugin has been closed') end |
#inner_http_input_options ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/logstash/inputs/logstash.rb', line 83 def @_inner_http_input_options ||= begin = { # directly-configurable 'host' => @host, 'port' => @port, # non-configurable codec 'codec' => plugin_factory.codec('json_lines').new(), 'additional_codecs' => {}, 'response_headers' => { 'Accept' => 'application/x-ndjson' }, # enrichment avoidance 'ecs_compatibility' => 'disabled', 'remote_host_target_field' => '[@metadata][void]', 'request_headers_target_field' => '[@metadata][void]', } if @username ['user'] = @username ['password'] = @password || report_invalid_config!('`password` is REQUIRED when `username` is provided') logger.warn("transmitting credentials over non-secured connection") if @ssl_enabled == false elsif @password report_invalid_config!('`password` not allowed unless `username` is configured') end if @ssl_enabled == false rejected_ssl_settings = @original_params.keys.select { |k| k.start_with?('ssl_') } - %w(ssl_enabled) report_invalid_config!("Explicit SSL-related settings not supported because `ssl_enabled => false`: #{rejected_ssl_settings}") if rejected_ssl_settings.any? else ['ssl_enabled'] = true ['ssl_cipher_suites'] = @ssl_cipher_suites if @original_params.include?('ssl_cipher_suites') ['ssl_supported_protocols'] = @ssl_supported_protocols if @original_params.include?('ssl_supported_protocols') ['ssl_handshake_timeout'] = @ssl_handshake_timeout .merge!() .merge!() end end end |
#inner_json_lines_codec_options ⇒ Object
164 165 166 167 168 169 |
# File 'lib/logstash/inputs/logstash.rb', line 164 def @_inner_json_lines_codec_options ||= { # enrichment avoidance 'ecs_compatibility' => 'disabled', } end |
#register ⇒ Object
56 57 58 59 60 |
# File 'lib/logstash/inputs/logstash.rb', line 56 def register logger.debug("registering inner HTTP input plugin") @internal_http.register logger.debug("inner HTTP input plugin has been registered") end |
#report_invalid_config!(message) ⇒ Object
171 172 173 |
# File 'lib/logstash/inputs/logstash.rb', line 171 def report_invalid_config!() fail(LogStash::ConfigurationError, ) end |
#run(queue) ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/logstash/inputs/logstash.rb', line 62 def run(queue) logger.debug("starting inner HTTP input plugin") @internal_http.run(QueueWrapper.new(queue, method(:decorate))) logger.debug("inner HTTP input plugin has exited normally") rescue => e logger.error("inner HTTP plugin has had an unrecoverable exception: #{e.} at #{e.backtrace.first}") raise end |
#ssl_identity_options ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/logstash/inputs/logstash.rb', line 127 def {}.tap do || if @ssl_certificate && @ssl_keystore_path report_invalid_config!('SSL identity can be configured with EITHER `ssl_certificate` OR `ssl_keystore_*`, but not both') elsif @ssl_certificate ['ssl_certificate'] = @ssl_certificate ['ssl_key'] = @ssl_key || report_invalid_config!('`ssl_key` is required when `ssl_certificate` is configured') ['ssl_key_passphrase'] = @ssl_key_passphrase unless @ssl_key_passphrase.nil? elsif @ssl_key report_invalid_config!('`ssl_key` is not allowed unless `ssl_certificate` is configured') elsif @ssl_key_passphrase report_invalid_config!('`ssl_key_passphrase` is not allowed unless `ssl_key` is configured') elsif @ssl_keystore_path ['ssl_keystore_path'] = @ssl_keystore_path ['ssl_keystore_password'] = @ssl_keystore_password || report_invalid_config!('`ssl_keystore_password` is REQUIRED when `ssl_keystore_path` is configured') elsif @ssl_keystore_password report_invalid_config!('`ssl_keystore_password` is not allowed unless `ssl_keystore_path` is configured') else report_invalid_config!('SSL identity MUST be configured with either `ssl_certificate`/`ssl_key` or `ssl_keystore_*`') end end end |
#ssl_trust_options ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/logstash/inputs/logstash.rb', line 150 def { 'ssl_client_authentication' => @ssl_client_authentication, }.tap do || if @ssl_certificate_authorities&.any? if @ssl_client_authentication == 'none' report_invalid_config!('`ssl_certificate_authorities` is not supported because `ssl_client_authentication => none`') end ['ssl_certificate_authorities'] = @ssl_certificate_authorities end end end |
#stop ⇒ Object
71 72 73 74 75 |
# File 'lib/logstash/inputs/logstash.rb', line 71 def stop logger.debug("stopping inner HTTP input plugin") @internal_http.stop logger.debug('inner HTTP plugin has been stopped') end |