Doris output plugin

This plugin is used to output data to Doris for logstash, use the HTTP protocol to interact with the Doris FE Http interface, and import data through Doris’s stream load.

Learn more about Doris Stream Load Logstash Doris Output Plugin - 图1 (opens new window)

Learn more about DorisLogstash Doris Output Plugin - 图2 (opens new window)

Install and compile

1.Download source code

2.compile

Execute under extension/logstash/ directory

gem build logstash-output-doris.gemspec

You will get logstash-output-doris-{version}.gem file in the same directory

3.Plug-in installation

copy logstash-output-doris-{version}.gem to the logstash installation directory

Executing an order

./bin/logstash-plugin install logstash-output-doris-{version}.gem

Install logstash-output-doris plugin

Configuration

Example:

Create a new configuration file in the config directory and name it logstash-doris.conf

The specific configuration is as follows:

  1. output {
  2. doris {
  3. http_hosts => [ "http://fehost:8030" ]
  4. user => user_name
  5. password => password
  6. db => "db_name"
  7. table => "table_name"
  8. label_prefix => "label_prefix"
  9. column_separator => ","
  10. }
  11. }

Configuration instructions:

Connection configuration:

ConfigurationExplanation
httphostsFE’s HTTP interactive address eg
userUser name, the user needs to have import permission for the doris table
passwordPassword
dbDatabase name
tableTable name
label_prefixImport the identification prefix, the final generated ID is {label_prefix}{db}{table}{time_stamp}

Load configuration:(Reference documentsLogstash Doris Output Plugin - 图3 (opens new window))

ConfigurationExplanation
column_separatorColumn separator, the default is \t
columnsUsed to specify the correspondence between the columns in the import file and the columns in the table
whereThe filter conditions specified by the import task
max_filter_ratioThe maximum tolerance rate of the import task, the default is zero tolerance
partitionPartition information of the table to be imported
timeouttimeout, the default is 600s
strict_modeStrict mode, the default is false
timezoneSpecify the time zone used for this import, the default is the East Eight District
exec_mem_limitImport memory limit, default is 2GB, unit is byte

Other configuration:

ConfigurationExplanation
save_on_failureIf the import fails to save locally, the default is true
save_dirLocal save directory, default is /tmp
automatic_retriesThe maximum number of retries on failure, the default is 3
batch_sizeThe maximum number of events processed per batch, the default is 100000
idle_flush_timeMaximum interval, the default is 20 (seconds)

Start Up

Run the command to start the doris output plugin:

{logstash-home}/bin/logstash -f {logstash-home}/config/logstash-doris.conf --config.reload.automatic

Complete usage example

1. Compile doris-output-plugin

1> Download the ruby compressed package and go to ruby official websiteLogstash Doris Output Plugin - 图4 (opens new window) to download it. The version 2.7.1 used here

2> Compile and install, configure ruby environment variables

3> Go to the doris source extension/logstash/ directory and execute

gem build logstash-output-doris.gemspec

Get the file logstash-output-doris-0.1.0.gem, and the compilation is complete

2. Install and configure filebeat (here use filebeat as input)

1> es official websiteLogstash Doris Output Plugin - 图5 (opens new window) Download the filebeat tar compression package and decompress it

2> Enter the filebeat directory and modify the configuration file filebeat.yml as follows:

  1. filebeat.inputs:
  2. - type: log
  3. paths:
  4. - /tmp/doris.data
  5. output.logstash:
  6. hosts: ["localhost:5044"]

/tmp/doris.data is the doris data path

3> Start filebeat:

./filebeat -e -c filebeat.yml -d "publish"

3.Install logstash and doris-out-plugin

1> es official websiteLogstash Doris Output Plugin - 图6 (opens new window) Download the logstash tar compressed package and decompress it

2> Copy the logstash-output-doris-0.1.0.gem obtained in step 1 to the logstash installation directory

3> execute

./bin/logstash-plugin install logstash-output-doris-0.1.0.gem

Install the plugin

4> Create a new configuration file logstash-doris.conf in the config directory as follows:

  1. input {
  2. beats {
  3. port => "5044"
  4. }
  5. }
  6. output {
  7. doris {
  8. http_hosts => [ "http://127.0.0.1:8030" ]
  9. user => doris
  10. password => doris
  11. db => "logstash_output_test"
  12. table => "output"
  13. label_prefix => "doris"
  14. column_separator => ","
  15. columns => "a,b,c,d,e"
  16. }
  17. }

The configuration here needs to be configured according to the configuration instructions

5> Start logstash:

./bin/logstash -f ./config/logstash-doris.conf —config.reload.automatic

4.Test Load

Add write data to /tmp/doris.data

echo a,b,c,d,e >> /tmp/doris.data

Observe the logstash log. If the status of the returned response is Success, the import was successful. At this time, you can view the imported data in the logstash_output_test.output table