Class: LogStash::Outputs::ElasticAppSearch

Inherits:
Base
  • Object
show all
Includes:
PluginMixins::DeprecationLoggerSupport, PluginMixins::EnterpriseSearch::SSLConfigs
Defined in:
lib/logstash/outputs/elastic_app_search.rb

Constant Summary collapse

ENGINE_WITH_SPRINTF_REGEX =
/^.*%\{.+\}.*$/.freeze

Instance Method Summary collapse

Instance Method Details

#multi_receive(events) ⇒ Object



68
69
70
71
72
73
74
75
76
77
# File 'lib/logstash/outputs/elastic_app_search.rb', line 68

def multi_receive(events)
  # because App Search has a limit of 100 documents per bulk
  events.each_slice(100) do |events|
    batch = format_batch(events)
    if @logger.trace?
      @logger.trace('Sending bulk to App Search', :size => batch.size, :data => batch.inspect)
    end
    index(batch)
  end
end

#registerObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/logstash/outputs/elastic_app_search.rb', line 48

def register
  log_message = "The App Search product is deprecated and not supported from version 9 of the Elastic Stack. " +
    "The Elastic App Search output plugin is deprecated and will only receive security updates and critical bug fixes. " +
    "Please migrate to the Elastic Connector for continued support. " +
    "For more details, please visit https://www.elastic.co/guide/en/search-ui/current/tutorials-elasticsearch.html"
  deprecation_logger.deprecated log_message

  @retry_disabled = false
  @client = LogStash::PluginMixins::EnterpriseSearch::AppSearch::Client.new(client_options, params: params)
  check_connection!
rescue => e
  if e.message =~ /401/
    raise ::LogStash::ConfigurationError, "Failed to connect to App Search. Please check your credentials. Error: #{e.message}"
  elsif e.message =~ /404/
    raise ::LogStash::ConfigurationError, "Failed to connect to App Search. Please check if url '#{@url}' is correct and you've created an engine with name '#{@engine}'. Error: #{e.message}"
  else
    raise ::LogStash::ConfigurationError, "Failed to connect to App Search. Error: #{e.message}"
  end
end