简体   繁体   中英

Set MySQL conf in JDBC Input plugin in Logstash

I am using the JDBC Input plugin in logstash to index data based on MySQL queries .

I am able to successfully index data and get output, however, I am stuck at this.

One of my queries requires setting the group_concat_max_len . Is there a way to accommodate this in the input plugin itself? Because I want to avoid setting this at the global level.

I referred to this site for different input parameters but nothing that solves my problem

Here is my sample input plugin:

input{
    jdbc{
        jdbc_connection_string=>"hostname"
        jdbc_user=>"user"
        jdbc_password=>"password"
        jdbc_driver_library=>"path/to/library"
        jdbc_driver_class=>"com.mysql.jdbc.Driver"
        lowercase_column_names => "false"
        statement_filepath => "query.sql"
    }

}

I also tried setting in the query.sql file, but looks like there should only one query be present.

Thanks for the help!!

If you are using docker-compose, just set this variable in the container.

version: '2.1'

services:
  db:
    image: mysql
    environment:
     - MYSQL_USER=root
     - MYSQL_PASSWORD=
     - MYSQL_DATABASE=mydb
     - MYSQL_ROOT_PASSWORD=
     - MYSQL_ROOT_PASSWORD=root
    command: --group_concat_max_len=65535
    ports:
      - "3306:3306"

Check it in your database: SELECT @@GLOBAL.group_concat_max_len;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM