Integrate Log Service with Apache Flume by using the aliyun-log-flume plugin to write and consume log data.
Background information
aliyun-log-flume is a plugin that connects Log Service with Apache Flume, enabling data exchange between Log Service and other systems such as HDFS and Kafka. The plugin provides a sink and a source.
-
Sink: Flume reads data from other data sources and writes it to Log Service.
-
Source: Flume consumes log data from Log Service and writes it to other systems.
For more information, see aliyun-log-flume.
Procedure
-
Download and install Apache Flume.
For more information, see Apache Flume.
-
Download the aliyun-log-flume plugin and place it in the
/flume/libdirectory.For more information, see aliyun-log-flume-1.3.jar.
-
In the
/flume/confdirectory, create a configuration file named flumejob.conf. -
Start Flume.
Sink
A sink writes data from other data sources to Log Service and supports two parsing formats:
-
SIMPLE: writes the entire Flume event as a single field to Log Service.
-
DELIMITED: treats the Flume event as separator-delimited data, parses it into fields based on the configured column names, and then writes them to Log Service.
The following table describes the sink parameters.
|
Parameter |
Required |
Description |
|
type |
Yes |
The type of the sink. Set this parameter to |
|
endpoint |
Yes |
The endpoint of the Log Service project. Example: |
|
project |
Yes |
The name of the Log Service project. |
|
LogStore |
Yes |
The name of the Logstore. |
|
accessKeyId |
Yes |
The AccessKey ID of your Alibaba Cloud account. We recommend that you use the AccessKey pair of a RAM user. For more information, see Create an AccessKey. |
|
accessKey |
Yes |
The AccessKey secret of your Alibaba Cloud account. We recommend that you use the AccessKey pair of a RAM user. For more information, see Create an AccessKey. |
|
batchSize |
No |
The number of data entries to write to Log Service in each batch. Default value: 1000. |
|
maxBufferSize |
No |
The size of the buffer queue. Default value: 1,000 entries. |
|
serializer |
No |
The event serialization format. Valid values:
|
|
columns |
No |
This parameter is required when |
|
separatorChar |
No |
This parameter is used when |
|
quoteChar |
No |
This parameter is used when |
|
escapeChar |
No |
This parameter is used when |
|
useRecordTime |
No |
Specifies whether to use the data's |
For sink configuration examples, see GitHub.
Source
A source consumes log data from Log Service and sends it to other systems. Two output formats are supported:
-
DELIMITED: writes data to Flume in delimited format.
-
JSON: writes data to Flume in JSON format.
The following table describes the source parameters.
|
Parameter |
Required |
Description |
|
type |
Yes |
The type of the source. Set this parameter to |
|
endpoint |
Yes |
The endpoint of the Log Service project. Example: |
|
project |
Yes |
The name of the Log Service project. |
|
LogStore |
Yes |
The name of the Logstore. |
|
accessKeyId |
Yes |
The AccessKey ID of your Alibaba Cloud account. We recommend that you use the AccessKey pair of a RAM user. For more information, see Create an AccessKey. |
|
accessKey |
Yes |
The AccessKey secret of your Alibaba Cloud account. We recommend that you use the AccessKey pair of a RAM user. For more information, see Create an AccessKey. |
|
heartbeatIntervalMs |
No |
The heartbeat interval between the client and Log Service. Default value: 30,000 ms. |
|
fetchIntervalMs |
No |
The data fetch interval. Default value: 100 ms. |
|
fetchInOrder |
No |
Specifies whether to consume data in sequential order. Default value: |
|
batchSize |
No |
The number of data entries to read in each batch. Default value: 100. |
|
consumerGroup |
No |
The name of the consumer group used for reading data. |
|
initialPosition |
No |
The initial position from which to start reading data. Valid values: begin, end, and timestamp. Default value: begin. Note
If a server-side checkpoint exists, it takes precedence. |
|
timestamp |
No |
This parameter is required when |
|
deserializer |
Yes |
The event deserialization format. Valid values:
|
|
columns |
No |
This parameter is required when |
|
separatorChar |
No |
This parameter is used when |
|
quoteChar |
No |
This parameter is used when |
|
escapeChar |
No |
This parameter is used when |
|
appendTimestamp |
No |
This parameter is used when |
|
sourceAsField |
No |
This parameter is used when |
|
tagAsField |
No |
This parameter is used when |
|
timeAsField |
No |
This parameter is used when |
|
useRecordTime |
No |
Specifies whether to use the original log time from Log Service for the Flume event's timestamp. If |
For source configuration examples, see GitHub.