|
| 1 | +--- |
| 2 | +description: Send logs to Amazon OpenSearch Service |
| 3 | +--- |
| 4 | + |
| 5 | +# OpenSearch |
| 6 | + |
| 7 | +The **opensearch** output plugin, allows to ingest your records into an [OpenSearch](https://opensearch.org/) database. The following instructions assumes that you have a fully operational OpenSearch service running in your environment. |
| 8 | + |
| 9 | +## Configuration Parameters |
| 10 | + |
| 11 | +| Key | Description | default | |
| 12 | +| :--- |:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| :--- | |
| 13 | +| Host | IP address or hostname of the target OpenSearch instance | 127.0.0.1 | |
| 14 | +| Port | TCP port of the target OpenSearch instance | 9200 | |
| 15 | +| Path | OpenSearch accepts new data on HTTP query path "/\_bulk". But it is also possible to serve OpenSearch behind a reverse proxy on a subpath. This option defines such path on the fluent-bit side. It simply adds a path prefix in the indexing HTTP POST URI. | Empty string | |
| 16 | +| Buffer\_Size | Specify the buffer size used to read the response from the OpenSearch HTTP service. This option is useful for debugging purposes where is required to read full responses, note that response size grows depending of the number of records inserted. To set an _unlimited_ amount of memory set this value to **False**, otherwise the value must be according to the [Unit Size](../../administration/configuring-fluent-bit/unit-sizes.md) specification. | 4KB | |
| 17 | +| Pipeline | OpenSearch allows to setup filters called pipelines. This option allows to define which pipeline the database should use. For performance reasons is strongly suggested to do parsing and filtering on Fluent Bit side, avoid pipelines. | | |
| 18 | +| AWS\_Auth | Enable AWS Sigv4 Authentication for Amazon OpenSearch Service | Off | |
| 19 | +| AWS\_Region | Specify the AWS region for Amazon OpenSearch Service | | |
| 20 | +| AWS\_STS\_Endpoint | Specify the custom sts endpoint to be used with STS API for Amazon OpenSearch Service | | |
| 21 | +| AWS\_Role\_ARN | AWS IAM Role to assume to put records to your Amazon cluster | | |
| 22 | +| AWS\_External\_ID | External ID for the AWS IAM Role specified with `aws_role_arn` | | |
| 23 | +| HTTP\_User | Optional username credential for access | | |
| 24 | +| HTTP\_Passwd | Password for user defined in HTTP\_User | | |
| 25 | +| Index | Index name | fluent-bit | |
| 26 | +| Type | Type name | \_doc | |
| 27 | +| Logstash\_Format | Enable Logstash format compatibility. This option takes a boolean value: True/False, On/Off | Off | |
| 28 | +| Logstash\_Prefix | When Logstash\_Format is enabled, the Index name is composed using a prefix and the date, e.g: If Logstash\_Prefix is equals to 'mydata' your index will become 'mydata-YYYY.MM.DD'. The last string appended belongs to the date when the data is being generated. | logstash | |
| 29 | +| Logstash\_DateFormat | Time format \(based on [strftime](http://man7.org/linux/man-pages/man3/strftime.3.html)\) to generate the second part of the Index name. | %Y.%m.%d | |
| 30 | +| Time\_Key | When Logstash\_Format is enabled, each record will get a new timestamp field. The Time\_Key property defines the name of that field. | @timestamp | |
| 31 | +| Time\_Key\_Format | When Logstash\_Format is enabled, this property defines the format of the timestamp. | %Y-%m-%dT%H:%M:%S | |
| 32 | +| Time\_Key\_Nanos | When Logstash\_Format is enabled, enabling this property sends nanosecond precision timestamps. | Off | |
| 33 | +| Include\_Tag\_Key | When enabled, it append the Tag name to the record. | Off | |
| 34 | +| Tag\_Key | When Include\_Tag\_Key is enabled, this property defines the key name for the tag. | \_flb-key | |
| 35 | +| Generate\_ID | When enabled, generate `_id` for outgoing records. This prevents duplicate records when retrying. | Off | |
| 36 | +| Id\_Key | If set, `_id` will be the value of the key from incoming record and `Generate_ID` option is ignored. | | |
| 37 | +| Write\_Operation | Operation to use to write in bulk requests. | create | |
| 38 | +| Replace\_Dots | When enabled, replace field name dots with underscore. | Off | |
| 39 | +| Trace\_Output | When enabled print the OpenSearch API calls to stdout \(for diag only\) | Off | |
| 40 | +| Trace\_Error | When enabled print the OpenSearch API calls to stdout when OpenSearch returns an error \(for diag only\) | Off | |
| 41 | +| Current\_Time\_Index | Use current time for index generation instead of message record | Off | |
| 42 | +| Logstash\_Prefix\_Key | When included: the value in the record that belongs to the key will be looked up and over-write the Logstash\_Prefix for index generation. If the key/value is not found in the record then the Logstash\_Prefix option will act as a fallback. Nested keys are not supported \(if desired, you can use the nest filter plugin to remove nesting\) | | |
| 43 | +| Suppress\_Type\_Name | When enabled, mapping types is removed and `Type` option is ignored. | Off | |
| 44 | +| Workers | Enables dedicated thread(s) for this output. Default value is set since version 1.8.13. For previous versions is 0. | 2 | |
| 45 | + |
| 46 | +> The parameters _index_ and _type_ can be confusing if you are new to OpenSearch, if you have used a common relational database before, they can be compared to the _database_ and _table_ concepts. Also see [the FAQ below](opensearch.md#faq) |
| 47 | +
|
| 48 | +### TLS / SSL |
| 49 | + |
| 50 | +OpenSearch output plugin supports TTL/SSL, for more details about the properties available and general configuration, please refer to the [TLS/SSL](tcp-and-tls.md) section. |
| 51 | + |
| 52 | +### write\_operation |
| 53 | + |
| 54 | +The write\_operation can be any of: |
| 55 | + |
| 56 | +| Operation | Description | |
| 57 | +| ------------- | ----------- | |
| 58 | +| create (default) | adds new data - if the data already exists (based on its id), the op is skipped.| |
| 59 | +| index | new data is added while existing data (based on its id) is replaced (reindexed).| |
| 60 | +| update | updates existing data (based on its id). If no data is found, the op is skipped.| |
| 61 | +| upsert | known as merge or insert if the data does not exist, updates if the data exists (based on its id).| |
| 62 | + |
| 63 | +**Please note, `Id_Key` or `Generate_ID` is required in update, and upsert scenario.** |
| 64 | + |
| 65 | +## Getting Started |
| 66 | + |
| 67 | +In order to insert records into an OpenSearch service, you can run the plugin from the command line or through the configuration file: |
| 68 | + |
| 69 | +### Command Line |
| 70 | + |
| 71 | +The **opensearch** plugin, can read the parameters from the command line in two ways, through the **-p** argument \(property\) or setting them directly through the service URI. The URI format is the following: |
| 72 | + |
| 73 | +```text |
| 74 | +es://host:port/index/type |
| 75 | +``` |
| 76 | + |
| 77 | +Using the format specified, you could start Fluent Bit through: |
| 78 | + |
| 79 | +```text |
| 80 | +$ fluent-bit -i cpu -t cpu -o es://192.168.2.3:9200/my_index/my_type \ |
| 81 | + -o stdout -m '*' |
| 82 | +``` |
| 83 | + |
| 84 | +which is similar to do: |
| 85 | + |
| 86 | +```text |
| 87 | +$ fluent-bit -i cpu -t cpu -o opensearch -p Host=192.168.2.3 -p Port=9200 \ |
| 88 | + -p Index=my_index -p Type=my_type -o stdout -m '*' |
| 89 | +``` |
| 90 | + |
| 91 | +### Configuration File |
| 92 | + |
| 93 | +In your main configuration file append the following _Input_ & _Output_ sections. You can visualize this configuration [here](https://link.calyptia.com/qhq) |
| 94 | + |
| 95 | +```python |
| 96 | +[INPUT] |
| 97 | + Name cpu |
| 98 | + Tag cpu |
| 99 | + |
| 100 | +[OUTPUT] |
| 101 | + Name opensearch |
| 102 | + Match * |
| 103 | + Host 192.168.2.3 |
| 104 | + Port 9200 |
| 105 | + Index my_index |
| 106 | + Type my_type |
| 107 | +``` |
| 108 | + |
| 109 | + |
| 110 | + |
| 111 | +## About OpenSearch field names |
| 112 | + |
| 113 | +Some input plugins may generate messages where the field names contains dots. This **opensearch** plugin replaces them with an underscore, e.g: |
| 114 | + |
| 115 | +```text |
| 116 | +{"cpu0.p_cpu"=>17.000000} |
| 117 | +``` |
| 118 | + |
| 119 | +becomes |
| 120 | + |
| 121 | +```text |
| 122 | +{"cpu0_p_cpu"=>17.000000} |
| 123 | +``` |
| 124 | + |
| 125 | +## FAQ |
| 126 | + |
| 127 | +### Fluent Bit + Amazon OpenSearch Service <a id="#aws-es"></a> |
| 128 | + |
| 129 | +The Amazon OpenSearch Service adds an extra security layer where HTTP requests must be signed with AWS Sigv4. This plugin supports Amazon OpenSearch Service with IAM Authentication. |
| 130 | + |
| 131 | +See [here](../../administration/aws-credentials.md) for details on how AWS credentials are fetched. |
| 132 | + |
| 133 | +Example configuration: |
| 134 | + |
| 135 | +```text |
| 136 | +[OUTPUT] |
| 137 | + Name opensearch |
| 138 | + Match * |
| 139 | + Host vpc-test-domain-ke7thhzoo7jawsrhmm6mb7ite7y.us-west-2.es.amazonaws.com |
| 140 | + Port 443 |
| 141 | + Index my_index |
| 142 | + Type my_type |
| 143 | + AWS_Auth On |
| 144 | + AWS_Region us-west-2 |
| 145 | + tls On |
| 146 | +``` |
| 147 | + |
| 148 | +Notice that the `Port` is set to `443`, `tls` is enabled, and `AWS_Region` is set. |
0 commit comments