The requested URL was not found on this server. 不管你信不信,反正我是没找到

请教一个logstash简单的获取数据的问题,获取的数据错误

Logstash | 作者 ljx95315 | 发布于2018年08月01日 | 阅读数:3250

我的logstash配置文件如下(方案是从oracle中导出数据,然后导入到mysql中去,以下是一个测试配置,仅仅获取oracle PERSON_INFO表的ID字段,准备让mysql来接受这个字段的数据):
 
input {
    stdin {
    }
    jdbc {
      jdbc_driver_library => "/usr/share/logstash/config/ojdbc6.jar"
      jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
      jdbc_connection_string => "jdbc:oracle:thin:@//192.168.10.5:1521/orcl"
      jdbc_user => "sdystr"
      jdbc_password => "shandong"

      jdbc_paging_enabled => "true"
      jdbc_page_size => "50000"
      jdbc_default_timezone => "Asia/Shanghai"

      statement => "select ID,INIT_SERVER_NO from Person_Info;"

      # schedule => "* * * * * Asia/Shanghai"
      type => ""#####LAB_SERVER_NO#####""

      record_last_run => "true"
      use_column_value => "true"
      tracking_column_type => "timestamp"
      tracking_column => "XXXXXX"
      last_run_metadata_path => "/usr/share/logstash/config/last_datetime/Person_Info"
      clean_run => "false"
      lowercase_column_names => "false"
    }
}

filter {
   json {
        source => "message"
        remove_field => ["message","@version","host","@timestamp"]
    }
}

output {
jdbc {
     driver_jar_path => "/opt/logstash-6.3.1/config/mysql-connector-java-8.0.11.jar"
     driver_class => "com.mysql.jdbc.Driver"
     connection_string => "jdbc:mysql://192.168.10.61:3306//ystr2?autoReconnect=true&usrSSL=true&user=ystr2&password=ystr2"
     statement => ["insert into table(column1,column2) values(?,?)","%{[message][1]}","%{[message][2]}"]
    }
}
 
然后我就启动了这个conf文件,之后输出没有报错,但是mysql收到的字段显示为图片那的格式,如果有解答,必有重谢,QQ247991998
 
获取失败.PNG
已邀请:

medcl - 今晚打老虎。

赞同来自: ljx95315

1. 你在上面的 filter 里面 remove_field 中,把 message 已经移除了,后面再 %{[message][1]} 肯定是拿不到的,并且 message 哪里来的?
2.你已经指定了列名(ID,INIT_SERVER_NO),直接通过各个列名就可以拿到数据的,如:%{ID}
output里面:  
    statement => ["insert into table(column1,column2) values(?,?)","%{ID}","%{INIT_SERVER_NO}"]

ljx95315

赞同来自:

要回复问题请先登录注册