Use the logstash-input-datahub plug-in

Updated at:

The logstash-input-datahub plug-in reads data from DataHub and sends it to a destination such as Elasticsearch.

Prerequisites

Before you begin, ensure that you have:

Configure the pipeline

Create a pipeline by following Use configuration files to manage pipelines. When configuring the pipeline, set the parameters described in the Parameters section. After you save and deploy the pipeline, Logstash reads data from DataHub and transfers it to the destination.

The following example shows a complete pipeline configuration:

input {
    datahub {
        access_id  => "<your-access-key-id>"
        access_key => "<your-access-key-secret>"
        endpoint   => "<datahub-endpoint>"
        project_name => "test_project"
        topic_name   => "test_topic"
        interval   => 5
        # cursor: start point per shard (leave blank to consume from the beginning)
        #cursor => {
        #    "0"=>"20000000000000000000000003110091"
        #    "2"=>"20000000000000000000000003110091"
        #    "1"=>"20000000000000000000000003110091"
        #    "4"=>"20000000000000000000000003110091"
        #    "3"=>"20000000000000000000000003110000"
        #}
        shard_ids => []
        pos_file  => "/ssd/1/<logstash-cluster-id>/logstash/data/<filename>"
    }
}
output {
    elasticsearch {
        hosts         => ["http://es-cn-mp91cbxsm000c****.elasticsearch.aliyuncs.com:9200"]
        user          => "elastic"
        password      => "your_password"
        index         => "datahubtest"
        document_type => "_doc"
    }
}
Important

By default, Alibaba Cloud Logstash supports data transmission only within the same virtual private cloud (VPC). If your DataHub data source is on the Internet, configure a Network Address Translation (NAT) gateway for your Logstash cluster. For more information, see Configure a NAT gateway for data transmission over the Internet.

Parameters

The following table describes the parameters supported by logstash-input-datahub.

ParameterTypeRequiredDefaultDescription
endpointstringYes—The endpoint used to access DataHub. For more information, see Endpoints.
access_idstringYes—The AccessKey ID of your Alibaba Cloud account.
access_keystringYes—The AccessKey secret of your Alibaba Cloud account.
project_namestringYes—The name of the DataHub project.
topic_namestringYes—The name of the DataHub topic.
pos_filestringYes—The path to the checkpoint file. Checkpoints take priority over cursor for resuming consumption.
retry_timesnumberNo-1The number of retries. -1 means no limit. 0 disables retries. A positive integer sets the exact retry count.
retry_intervalnumberNo—The interval between retries, in seconds.
shard_idsarrayNo[] (all shards)The shards to consume. Leave blank to consume all shards.
cursorstringNo— (from beginning)The start point for consumption per shard. Leave blank to consume from the beginning.
enable_pbbooleanNotrueWhether to use Protocol Buffers (Protobuf) for data transfer. Set to false if Protobuf is not supported in your environment.
compress_methodstringNo— (no compression)The compression algorithm for data transfer. Valid values: lz4, deflate.
print_debug_infobooleanNofalseWhether to print DataHub debugging information. Setting this to true generates a large volume of output. Use only for script debugging.