本人使用logstash output jdbc插件,因想使用动态的sql,但是到了output里面 给jdbc 参数赋值的时候,总是会被转为字符串,导致jdbc插件,解析不了。数据如下:
{
"area" => 35,
"level" => 85,
"openId" => "469358",
"@metadata" => {
"ip_address" => "192.168.2.2",
"beat" => "filebeat",
"version" => "7.4.2",
"type" => "_doc"
},
"statementArray" => [
[0] "insert into test(uuid,token)values(?,?)",
[1] "3500057,1"
],
"channel" => "1",
"count" => 4,
"mid" => 205001,
"type" => 1,
"uuid" => "3500057",
"sendTime" => 1574073183032,
"sql" => "insert into test(uuid,token)values(?,?)",
"token" => 1,
"addType" => 127,
"@timestamp" => 2019-11-25T04:58:36.700Z,
"data_value" => [
[0] "3500057",
[1] 1
],
"roleName" => "泣花之无极",
"key" => "test",
"mRank" => 12
}
配置文件jdbc输出:
jdbc{
driver_jar_path => "D:\elk\logstash-7.4.2\bin\mysql-connector-java-8.0.18.jar"
driver_class => "com.mysql.cj.jdbc.Driver"
connection_string => "jdbc:mysql://127.0.0.1:3306/ddt2?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true"
username => "root"
password => "123456"
unsafe_statement => true
statement => "%{[jdbc_statement]}"
}
{
"area" => 35,
"level" => 85,
"openId" => "469358",
"@metadata" => {
"ip_address" => "192.168.2.2",
"beat" => "filebeat",
"version" => "7.4.2",
"type" => "_doc"
},
"statementArray" => [
[0] "insert into test(uuid,token)values(?,?)",
[1] "3500057,1"
],
"channel" => "1",
"count" => 4,
"mid" => 205001,
"type" => 1,
"uuid" => "3500057",
"sendTime" => 1574073183032,
"sql" => "insert into test(uuid,token)values(?,?)",
"token" => 1,
"addType" => 127,
"@timestamp" => 2019-11-25T04:58:36.700Z,
"data_value" => [
[0] "3500057",
[1] 1
],
"roleName" => "泣花之无极",
"key" => "test",
"mRank" => 12
}
配置文件jdbc输出:
jdbc{
driver_jar_path => "D:\elk\logstash-7.4.2\bin\mysql-connector-java-8.0.18.jar"
driver_class => "com.mysql.cj.jdbc.Driver"
connection_string => "jdbc:mysql://127.0.0.1:3306/ddt2?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true"
username => "root"
password => "123456"
unsafe_statement => true
statement => "%{[jdbc_statement]}"
}
2 个回复
SilenceRain - 22
赞同来自:
zhahuan
赞同来自: