The logstash-output-oss plug-in transfers data from Alibaba Cloud Logstash pipelines to Object Storage Service (OSS). It is an open source plug-in maintained by Alibaba Cloud. For the source code, see logstash-output-oss.
Alibaba Cloud Logstash supports data transfer only within a virtual private cloud (VPC). If your data source is on the Internet, configure a NAT gateway before proceeding. For more information, see Configure a NAT gateway for data transfer over the Internet.
Prerequisites
Before you begin, ensure that you have:
-
Installed the logstash-output-oss plug-in. For more information, see Install and remove a plug-in.
-
Activated OSS. For more information, see Activate OSS.
-
Created a read/write OSS bucket and obtained the AccessKey ID and AccessKey secret of an account with write permissions on the bucket. For more information, see Create buckets.
-
Prepared your data sources. The plug-in supports all Logstash input plug-ins. For a full list, see Input plugins.
Configure the plug-in
Create a pipeline using a configuration file, then configure the output section with the oss plug-in parameters. After you save and deploy the pipeline, Alibaba Cloud Logstash transfers data from your data sources to OSS.
For instructions on creating a pipeline, see Use configuration files to manage pipelines.
The following example configures a pipeline that reads from Beats and writes to OSS:
input {
beats {
port => "8044" # required
codec => json {
charset => "UTF-8"
}
}
}
output {
oss {
endpoint => "http://oss-cn-hangzhou-internal.aliyuncs.com" # required
bucket => "zl-log-output-test" # required
access_key_id => "LTAI****************" # required
access_key_secret => "yourAccessKeySecret" # required
temporary_directory => "/ssd/1/<Logstash cluster ID>/logstash/data/22" # required
prefix => "oss/database" # optional, default: empty
recover => true # optional, default: true
rotation_strategy => "size_and_time" # optional, default: size_and_time
time_rotate => 1 # optional, default: 15 (minutes)
size_rotate => 1000 # optional, default: 31457280 (bytes)
encoding => "gzip" # optional, default: none
additional_oss_settings => {
max_connections_to_oss => 1024 # optional, default: 1024
secure_connection_enabled => false # optional, default: false
}
codec => json {
charset => "UTF-8"
}
}
}
Alibaba Cloud Logstash currently supports data transfer only within the same virtual private cloud (VPC). To transfer data over the public network, you must configure NAT. For more information, see Configure NAT for public network data transfer.
Parameters
The following table describes all parameters supported by logstash-output-oss.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
endpoint |
String | Yes | — | The OSS endpoint. For endpoint values by region, see Regions and endpoints. |
bucket |
String | Yes | — | The name of the OSS bucket. |
access_key_id |
String | Yes | — | The AccessKey ID of an account with write permissions on the OSS bucket. |
access_key_secret |
String | Yes | — | The AccessKey secret of an account with write permissions on the OSS bucket. |
temporary_directory |
String | Yes | — | The local directory used to cache data before upload to OSS. Set the value to /ssd/1/<Logstash cluster ID>/logstash/data/<customized>. The directory is deleted within seconds after the transfer completes. |
prefix |
String | No | (empty) | The prefix applied to file names. Important
Setting this parameter may create many temporary files on your local machine. |
recover |
Boolean | No | true |
Whether to resume uploading local data if the program exits unexpectedly. |
rotation_strategy |
String, one of size, time, size_and_time |
No | size_and_time |
Controls when a file is closed and uploaded to OSS. With size, the file rotates when its size reaches the size_rotate threshold. With time, the file rotates when its age reaches the time_rotate threshold. With size_and_time, the file rotates when either threshold is reached first. |
size_rotate |
Number | No | 31457280 |
The file size threshold for rotation, in bytes. This parameter is valid only when rotation_strategy is size. |
time_rotate |
Number | No | 15 |
The file age threshold for rotation, in minutes. This parameter is valid only when rotation_strategy is time. |
upload_workers_count |
Number | No | — | The number of concurrent upload threads. |
upload_queue_size |
Number | No | — | The size of the upload queue. |
encoding |
String, one of gzip, none |
No | none |
The encoding applied to files before upload. |
additional_oss_settings |
Hash | No | — | Additional OSS client settings. See the sub-parameters below. |
additional_oss_settings sub-parameters
| Sub-parameter | Default | Description |
|---|---|---|
server_side_encryption_algorithm |
— | The server-side encryption algorithm. Only AES-256 is supported. |
secure_connection_enabled |
false |
Whether to use HTTPS for the OSS connection. |
max_connections_to_oss |
1024 |
The maximum number of concurrent connections to OSS. |
Temporary files
While transferring data, the plug-in caches data in a temporary file on your local machine and uploads it to OSS periodically. Use the temporary_directory parameter to specify where this file is stored.
A temporary file path follows this format:
/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
The path segments are described below:
| Path segment | Description |
|---|---|
/ssd/1/<Logstash cluster ID>/logstash/data/ |
The directory specified by temporary_directory. |
eaced620-e972-0136-2a14-02b7449b**** |
A randomly generated universally unique identifier (UUID). |
logstash/1 |
The OSS object prefix. |
ls.oss |
The temporary file, which is generated by the logstash-output-oss plug-in. |
2018-12-24T14.27 |
The timestamp when the temporary file was created. |
part-0 |
The prefix of the temporary file. |
.data |
The file extension. .gz if encoding is set to gzip; otherwise .data. |
What's next
-
To install or remove plug-ins, see Install and remove a plug-in.
-
To manage pipelines using configuration files, see Use configuration files to manage pipelines.