Class: LogStash::Outputs::Logstash
- Inherits:
-
Base
- Object
- Base
- LogStash::Outputs::Logstash
- Extended by:
- PluginMixins::ValidatorSupport::RequiredHostOptionalPortValidationAdapter
- Includes:
- PluginMixins::NormalizeConfigSupport
- Defined in:
- lib/logstash/outputs/logstash.rb
Constant Summary collapse
- DEFAULT_PORT =
9800.freeze
- RETRIABLE_CODES =
[429, 500, 502, 503, 504]
- RETRYABLE_MANTICORE_EXCEPTIONS =
[ ::Manticore::Timeout, ::Manticore::SocketException, ::Manticore::ClientProtocolException, ::Manticore::ResolutionFailure, ::Manticore::SocketTimeout ]
- RETRYABLE_EXCEPTION_PATTERN =
Regexp.union([ /Connection reset by peer/i, /Read Timed out/i, ])
Instance Attribute Summary collapse
- #http_client ⇒ Object readonly private
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(*a) ⇒ Logstash
constructor
A new instance of Logstash.
- #multi_receive(events) ⇒ Object
- #register ⇒ Object
- #stop ⇒ Object
- #validate_auth_settings! ⇒ Object
- #validate_ssl_identity_options! ⇒ Object
- #validate_ssl_trust_options! ⇒ Object
Constructor Details
#initialize(*a) ⇒ Logstash
Returns a new instance of Logstash.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/logstash/outputs/logstash.rb', line 61 def initialize(*a) super if original_params.include?('codec') fail LogStash::ConfigurationError, 'The `logstash` output does not have an externally-configurable `codec`' end @headers = { "Content-Type" => "application/x-ndjson".freeze, "Content-Encoding" => "gzip".freeze }.freeze logger.debug("`logstash` output plugin has been initialized") end |
Instance Attribute Details
#http_client ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
59 60 61 |
# File 'lib/logstash/outputs/logstash.rb', line 59 def http_client @http_client end |
Instance Method Details
#close ⇒ Object
152 153 154 155 156 |
# File 'lib/logstash/outputs/logstash.rb', line 152 def close logger.debug("Closing `logstash` output plugin") http_client.close logger.debug("`logstash` output plugin has been closed") end |
#multi_receive(events) ⇒ Object
142 143 144 145 146 |
# File 'lib/logstash/outputs/logstash.rb', line 142 def multi_receive(events) return if events.empty? send_events(events) end |
#register ⇒ Object
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 |
# File 'lib/logstash/outputs/logstash.rb', line 76 def register logger.debug("Registering `logstash` output plugin") @username = normalize_config(:username) do |normalize| normalize.with_deprecated_alias(:user) end # remove after deprecating user in the http-mixin @user = @username ? @username.freeze : @user validate_auth_settings! if @ssl_enabled == false rejected_ssl_settings = @original_params.keys.select { |k| k.start_with?('ssl_') } - %w(ssl_enabled) fail(LogStash::ConfigurationError, "Explicit SSL-related settings not supported because `ssl_enabled => false`: #{rejected_ssl_settings}") if rejected_ssl_settings.any? end # if we don't initialize now, we get runtime error when sending events if there are issues with configs @http_client = client fail(LogStash::ConfigurationError, "`hosts` must not be empty") if @hosts.empty? @load_balancer = LoadBalancer.new(normalize_host_uris) logger.debug("`logstash` output plugin has been registered") end |
#stop ⇒ Object
148 149 150 |
# File 'lib/logstash/outputs/logstash.rb', line 148 def stop logger.debug("`logstash` output plugin has been stopped") end |
#validate_auth_settings! ⇒ Object
104 105 106 107 108 109 110 111 |
# File 'lib/logstash/outputs/logstash.rb', line 104 def validate_auth_settings! if @username fail(LogStash::ConfigurationError, '`password` is REQUIRED when `username` is provided') if @password.nil? logger.warn("Transmitting credentials over non-secured connection") if @ssl_enabled == false elsif @password fail(LogStash::ConfigurationError, '`password` not allowed unless `username` is configured') end end |
#validate_ssl_identity_options! ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/logstash/outputs/logstash.rb', line 113 def if @ssl_certificate && @ssl_keystore_path fail(LogStash::ConfigurationError, "SSL identity can be configured with EITHER `ssl_certificate` OR `ssl_keystore_*`, but not both") elsif @ssl_certificate fail(LogStash::ConfigurationError, "`ssl_key` is REQUIRED when `ssl_certificate` is provided") if @ssl_key.nil? elsif @ssl_key fail(LogStash::ConfigurationError, "`ssl_key` is not allowed unless `ssl_certificate` is configured") elsif @ssl_keystore_path fail(LogStash::ConfigurationError, "`ssl_keystore_password` is REQUIRED when `ssl_keystore_path` is provided") if @ssl_keystore_password.nil? elsif @ssl_keystore_password fail(LogStash::ConfigurationError, "`ssl_keystore_password` is not allowed unless `ssl_keystore_path` is configured") else # acceptable end end |
#validate_ssl_trust_options! ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/logstash/outputs/logstash.rb', line 129 def if @ssl_certificate_authorities&.any? && @ssl_truststore_path fail(LogStash::ConfigurationError, "SSL trust can be configured with EITHER `ssl_certificate_authorities` OR `ssl_truststore_*`, but not both") elsif @ssl_certificate_authorities&.any? fail(LogStash::ConfigurationError, "SSL Certificate Authorities cannot be configured when `ssl_verification_mode => none`") if @ssl_verification_mode == 'none' elsif @ssl_truststore_path fail(LogStash::ConfigurationError, "SSL Truststore cannot be configured when `ssl_verification_mode => none`") if @ssl_verification_mode == 'none' fail(LogStash::ConfigurationError, "`ssl_truststore_password` is REQUIRED when `ssl_truststore_path` is provided") if @ssl_truststore_password.nil? elsif @ssl_truststore_password fail(LogStash::ConfigurationError, "`ssl_truststore_password` not allowed unless `ssl_truststore_path` is configured") end end |