logstash input jdbc 如何填充多值字段?
logstash input jdbc how to populate multi value field?
我可以像这样放置一个包含多值字段 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"
}
}
您可以利用 mutate/split
filter 来实现您想要的:
filter {
mutate {
split => {
"categories" => ","
"tagids" => ","
}
}
}
我可以像这样放置一个包含多值字段 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"
}
}
您可以利用 mutate/split
filter 来实现您想要的:
filter {
mutate {
split => {
"categories" => ","
"tagids" => ","
}
}
}