Elasticsearch
Send logs to Elasticsearch (including Amazon OpenSearch Service)
The es output plugin lets you ingest your records into an Elasticsearch database. To use this plugin, you must have an operational Elasticsearch service running in your environment.
Configuration Parameters
Key | Description | Default |
---|---|---|
| IP address or hostname of the target Elasticsearch instance |
|
| TCP port of the target Elasticsearch instance |
|
| Elasticsearch accepts new data on HTTP query path | Empty string |
| Set payload compression mechanism. Option available is | none |
| Specify the buffer size used to read the response from the Elasticsearch HTTP service. Use for debugging purposes where required to read full responses. Response size grows depending of the number of records inserted. To use an unlimited amount of memory, set this value to |
|
| Define which pipeline the database should use. For performance reasons, it's strongly suggested to do parsing and filtering on Fluent Bit side, and avoid pipelines. | none |
| Enable AWS Sigv4 Authentication for Amazon OpenSearch Service. |
|
| Specify the AWS region for Amazon OpenSearch Service. | none |
| Specify the custom STS endpoint to be used with STS API for Amazon OpenSearch Service | none |
| AWS IAM Role to assume to put records to your Amazon cluster | none |
| External ID for the AWS IAM Role specified with | none |
| Service name to use in AWS Sigv4 signature. For integration with Amazon OpenSearch Serverless, set to |
|
| AWS profile name |
|
| If using Elastic's Elasticsearch Service you can specify the | none |
| Specify the credentials to use to connect to Elastic's Elasticsearch Service running on Elastic Cloud | none |
| Optional username credential for Elastic X-Pack access | none |
| Password for user defined in | none |
| Index name |
|
| Type name |
|
| Enable Logstash format compatibility. This option takes a Boolean value: |
|
| When |
|
| When included: the value of the key in the record will be evaluated as key reference and overrides | none |
| Set a separator between |
|
| Time format based on strftime to generate the second part of the Index name. |
|
| When |
|
| When |
|
| When |
|
| When enabled, it append the Tag name to the record. |
|
| When |
|
| When enabled, generate |
|
| If set, | none |
|
|
|
| When enabled, replace field name dots with underscore. Required by Elasticsearch 2.0-2.3. |
|
| Print all ElasticSearch API request payloads to |
|
| If ElasticSearch returns an error, print the ElasticSearch API request and response for diagnostics. |
|
| Use current time for index generation instead of message record. |
|
| When enabled, mapping types is removed and |
|
| The number of workers to perform flush operations for this output. |
|
If you have used a common relational database, the parameters index
and type
can be compared to the database
and table
concepts.
TLS / SSL
Elasticsearch output plugin supports TLS/SSL. For more details about the properties available and general configuration, refer toTLS/SSL.
write_operation
write_operation
The write_operation
can be any of:
Operation | Description |
---|---|
| Adds new data. If the data already exists (based on its id), the op is skipped. |
| New data is added while existing data (based on its id) is replaced (reindexed). |
| Updates existing data (based on its id). If no data is found, the op is skipped. |
| Merge or insert if the data doesn't exist, updates if the data exists (based on its id). |
Id_Key
or Generate_ID
is required for update
and upsert
.
Get started
To insert records into an Elasticsearch service, you run the plugin from the command line or through the configuration file:
Command Line
The es plugin can read the parameters from the command line in two ways:
Through the
-p
argument (property).Setting them directly through the service URI.
The URI format is the following:
Using the format specified, you could start Fluent Bit through:
Which is similar to the following command:
Configuration File
In your main configuration file append the following Input
and Output
sections.
About Elasticsearch field names
Some input plugins can generate messages where the field names contains dots. For Elasticsearch 2.0, this isn't allowed. The current es plugin replaces them with an underscore:
becomes
Use Fluent Bit ElasticSearch plugin with other services
Connect to Amazon OpenSearch or Elastic Cloud with the ElasticSearch plugin.
Amazon OpenSearch Service
The Amazon OpenSearch Service adds an extra security layer where HTTP requests must be signed with AWS Sigv4. Fluent Bit v1.5 introduced full support for Amazon OpenSearch Service with IAM Authentication.
See details on how AWS credentials are fetched.
Example configuration:
Be aware that the Port
is set to 443
, tls
is enabled, and AWS_Region
is set.
Use Fluent Bit with Elastic Cloud
Fluent Bit supports connecting to Elastic Cloud by providing the cloud_id
and the cloud_auth
settings. cloud_auth
uses the elastic
user and password provided when the cluster was created. For details refer to the Cloud ID usage page.
Example configuration:
In Elastic Cloud version 8 and great, the type option must be removed by setting Suppress_Type_Name On
.
Without this you will see errors like:
Troubleshooting
Use the following information to help resolve errors using the ElasticSearch plugin.
Using multiple types in a single index
Elasticsearch 6.0 can't create multiple types in a single index. An error message like the following indicates you need to update your configuration to use a single type on each index.
This means that you can't set up your configuration like the following:.
For details, read the official blog post on that issue.
Mapping type names can't start with underscores (_
)
_
)Fluent Bit v1.5 changed the default mapping type from flb_type
to _doc
, matching the recommendation from Elasticsearch for version 6.2 and greater (see commit with rationale).
This doesn't work in Elasticsearch versions 5.6 through 6.1 (discussion and fix).
Ensure you set an explicit map such as doc
or flb_type
in the configuration, as seen on the last line:
Validation failures
In Fluent Bit v1.8.2 and greater, Fluent Bit started using create
method (instead of index
) for data submission. This makes Fluent Bit compatible with Datastream, introduced in Elasticsearch 7.9. You might see errors like:
If you see action_request_validation_exception
errors on your pipeline with Fluent Bit versions greater than v1.8.2, correct them by turning on Generate_ID
as follows:
Logstash_Prefix_Key
Logstash_Prefix_Key
The following snippet demonstrates using the namespace name as extracted by the kubernetes
filter as logstash
prefix:
For records that don't have the field kubernetes.namespace_name
, the default prefix logstash
will be used.
Last updated