The logstash-output-oss plug-in allows you to transfer data to Object Storage Service (OSS).
logstash-output-oss is an open source plug-in maintained by Alibaba Cloud. For more information, see logstash-output-oss.
Prerequisites
The logstash-output-oss plug-in is installed.
For more information, see Install a Logstash plug-in.
OSS is activated.
For more information, see Activate OSS.
A read/write OSS bucket is created. The AccessKey ID and AccessKey secret of your account that has write permissions on the OSS bucket are obtained.
For more information, see Create buckets.
Data sources are prepared.
The data sources can be selected from all the input plug-ins that are supported. For more information, see Input plugins.
logstash-output-oss application
After the prerequisites are met, you can create a pipeline based on the instructions provided in Use configuration files to manage pipelines. When you create a pipeline, configure the pipeline parameters based on the descriptions that are provided in the table of the Parameters section. After you configure the parameters, you must save the settings and deploy the pipeline. Then, Alibaba Cloud Logstash is triggered to transfer data from data sources to OSS.
The following example shows how to transfer data from Beats to OSS:
input {
beats {
port => "8044"
codec => json {
charset => "UTF-8"
}
}
output {
oss {
endpoint => "http://oss-cn-hangzhou-internal.aliyuncs.com"
bucket => "zl-log-output-test"
access_key_id => "LTAIaxxxxx******"
access_key_secret => "zuxxxx8hBpXs3e6i******"
prefix => "oss/database"
recover => true
rotation_strategy => "size_and_time"
time_rotate => 1
size_rotate => 1000
temporary_directory => "/ssd/1/<Logstash cluster ID>/logstash/data/22"
encoding => "gzip"
additional_oss_settings => {
max_connections_to_oss => 1024
secure_connection_enabled => false
}
codec => json {
charset => "UTF-8"
}
}
}
Alibaba Cloud Logstash supports data transmission only within a virtual private cloud (VPC). If source data is on the Internet, configure a NAT gateway to access Alibaba Cloud Logstash over the Internet. For more information, see Configure a NAT gateway for data transmission over the Internet.
Parameters
The following table describes the parameters supported by logstash-output-oss.
Parameter | Type | Required | Description |
| String | Yes | The endpoint that is used to access OSS. For more information, see Regions and endpoints. |
| String | Yes | The name of the OSS bucket. |
| String | Yes | The AccessKey ID of your account that has write permissions on the OSS bucket. |
| String | Yes | The AccessKey secret of your account that has write permissions on the OSS bucket. |
| String | No | The prefix of file names. If this parameter is not specified, it is empty by default. Important You can set this parameter to a string. In this case, many temporary files may be created on your on-premises machine. |
| Boolean | No | Specifies whether to continue to upload the data on your on-premises machine if the program exits abnormally. Default value: true. |
| Hash | No | Additional OSS client configurations. Valid values:
|
| String | Yes | The temporary directory that you use to cache data before the data is uploaded to OSS. Set the value to |
| String | No | The file rotation strategy. Valid values: |
| Number | No | If the size of a file is greater than or equal to the value of |
| Number | No | If the lifecycle of a file is greater than or equal to the value of |
| Number | No | The number of threads that are used to upload data at the same time. |
| Number | No | The size of the upload queue. |
| String | No | The method that is used to encode messages before you upload files to OSS. Both standard compression and GZIP compression are supported. Valid values: |
Temporary files
When the logstash-output-oss plug-in transfers data to OSS, the plug-in creates a temporary file on your on-premises machine. Data is temporarily stored in this file. The logstash-output-oss plug-in transfers data to OSS on a regular basis. You can use the temporary_directory
parameter to specify the path of the temporary file if you have specific requirements on the path.
The following example shows a temporary file path:
/ssd/1/<Logstash cluster ID>/logstash/data/eaced620-e972-0136-2a14-02b7449b****/logstash/1/ls.oss.eaced620-e972-0136-2a14-02b7449b****.2018-12-24T14.27.part-0.data
Path element | Description |
/ssd/1/<Logstash cluster ID>/logstash/data/ | The temporary file directory specified by |
eaced620-e972-0136-2a14-02b7449b**** | The random Universally Unique Identifier (UUID). |
logstash/1 | The OSS object prefix. |
ls.oss | Indicates that the temporary file is generated by the logstash-output-oss plug-in. |
2018-12-24T14.27 | The time when the temporary file was created. |
part-0 | The prefix of the temporary file. |
.data | The file name extension. If |