【问题标题】:logstash input jdbc how to populate multi value field?logstash输入jdbc如何填充多值字段?
【发布时间】:2021-12-24 12:56:14
【问题描述】:

我可以像这样放置具有多值字段tagids 的文档,但是如何使用logstash 输入jdbc 填充具有多值的字段。

PUT /song/_doc/0
{
  "artist_name":"test",
  "artistid":0,
  "categories":[4,5,6],
  "created_at":"2021-12-13T00:00:00Z",
  "name":"test",
  "name_pinyin":"csgq",
  "tagids":[1,2,3]
}

目前我使用 jdbc 配置,但它以 1,2,3 作为一个关键字。怎么做成数组?

input {
  jdbc {
    jdbc_driver_library => ""
    jdbc_driver_class => "com.mysql.jdbc.Driver"
    jdbc_connection_string => "jdbc:............."
    jdbc_user => ""
    jdbc_password => ""
    schedule => "* * * * *"
    statement => "SELECT songid,name,name_pinyin,artistid,artist_name,'1,2,3' as tagids, '4,5,6' as categories,create_at from song"
  }
}

【问题讨论】:

    标签: elasticsearch jdbc logstash


    【解决方案1】:

    您可以利用mutate/split filter 来实现您想要的:

    filter {
      mutate {
         split => { 
            "categories" => "," 
            "tagids" => "," 
         }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2019-05-08
      • 1970-01-01
      • 2021-10-22
      • 2016-11-06
      • 1970-01-01
      • 2016-03-25
      • 2018-06-06
      • 1970-01-01
      • 2015-03-31
      相关资源
      最近更新 更多