This is a plugin for Logstash which outputs to Amazon OpenSearch Service (successor to Amazon Elasticsearch Service) using SigV4 signing.
This library is licensed under Apache License 2.0.
The following table shows the versions of logstash and logstash-output-amazon_es plugin was built with.
logstash-output-amazon_es | Logstash |
---|---|
6.0.0 | < 6.0.0 |
6.4.2 | >= 6.0.0 |
7.0.1 | >= 7.0.0 |
7.1.0 | >= 7.0.0 |
Also, logstash-output-amazon_es plugin versions 6.4.0 and newer are tested to be compatible with Elasticsearch 6.5 and greater.
logstash-output-amazon_es | Elasticsearch |
---|---|
6.4.0+ | 6.5+ |
To install the latest version, use the normal Logstash plugin script.
bin/logstash-plugin install logstash-output-amazon_es
If you want to use old version of logstash-output-amazon_es, you can use the --version
flag to specify the version. For example:
bin/logstash-plugin install --version 6.4.2 logstash-output-amazon_es
To run the Logstash Output Amazon Elasticsearch Service plugin, simply add a configuration following the below documentation.
An example configuration:
output {
amazon_es {
hosts => ["foo.us-east-1.es.amazonaws.com"]
region => "us-east-1"
# aws_access_key_id and aws_secret_access_key are optional if instance profile is configured
aws_access_key_id => 'ACCESS_KEY'
aws_secret_access_key => 'SECRET_KEY'
index => "production-logs-%{+YYYY.MM.dd}"
}
}
- hosts (array of string) - the Amazon Elasticsearch Service domain endpoint (e.g.
["foo.us-east-1.es.amazonaws.com"]
) - region (string, :default => "us-east-1") - region where the domain is located
-
Credential parameters:
- aws_access_key_id, :validate => :string - optional AWS access key
- aws_secret_access_key, :validate => :string - optional AWS secret key
The credential resolution logic can be described as follows:
- User passed
aws_access_key_id
andaws_secret_access_key
inamazon_es
configuration - Environment variables -
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
(RECOMMENDED since they are recognized by all the AWS SDKs and CLI except for .NET), orAWS_ACCESS_KEY
andAWS_SECRET_KEY
(only recognized by Java SDK) - Credential profiles file at the default location (
~/.aws/credentials
) shared by all AWS SDKs and the AWS CLI - Instance profile credentials delivered through the Amazon EC2 metadata service
-
template (path) - You can set the path to your own template here, if you so desire. If not set, the included template will be used.
-
template_name (string, default => "logstash") - defines how the template is named inside Elasticsearch
-
port (string, default 443) - Amazon Elasticsearch Service listens on port 443 for HTTPS (default) and port 80 for HTTP. Tweak this value for a custom proxy.
-
protocol (string, default https) - The protocol used to connect to the Amazon Elasticsearch Service
-
max_bulk_bytes - The max size for a bulk request in bytes. Default is 20MB. It is recommended not to change this value unless needed. For guidance on changing this value, please consult the table for network limits for your instance type: https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/aes-limits.html#network-limits
After 6.4.0, users can't set batch size in this output plugin config. However, users can still set batch size in logstash.yml file.
Starting logstash-output-amazon_es v7.1.0, we have introduced the following optional parameters to resolve specific use cases:
- service_name (string, default => "es") - Users can define any service name to which the plugin will send a SigV4 signed request
- skip_healthcheck (boolean, default => false) - Boolean to skip healthcheck API and set the major ES version to 7
- skip_template_installation (boolean, default => false) - Boolean to allow users to skip installing templates in usecases that don't require them
To get started, you can install JRuby with the Bundler gem using RVM
rvm install jruby-9.2.5.0
-
Verify JRuby is already installed
jruby -v
-
Install dependencies:
bundle install
-
Update your dependencies:
bundle install
-
Run unit tests:
bundle exec rspec
-
Edit Logstash
Gemfile
and add the local plugin path, for example:gem "logstash-output-amazon_es", :path => "/your/local/logstash-output-amazon_es"
-
Install the plugin:
# Logstash 2.3 and higher bin/logstash-plugin install --no-verify # Prior to Logstash 2.3 bin/plugin install --no-verify
-
Run Logstash with your plugin:
bin/logstash -e 'output {amazon_es {}}'
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply re-run Logstash.
Before build your Gemfile
, please make sure use JRuby. Here is how you can know your local Ruby version:
rvm list
Please make sure you current using JRuby. Here is how you can change to JRuby
rvm jruby-9.2.5.0
You can use the same 3.1 method to run your plugin in an installed Logstash by editing its Gemfile
and pointing the :path
to your local plugin development directory. You can also build the gem and install it using:
-
Build your plugin gem:
gem build logstash-output-amazon_es.gemspec
-
Install the plugin from the Logstash home. Please be sure to check the version number against the actual Gem file. Run:
bin/logstash-plugin install /your/local/logstash-output-amazon_es/logstash-output-amazon_es-7.0.1-java.gem
-
Start Logstash and test the plugin.
All contributions are welcome: ideas, patches, documentation, bug reports, and complaints.