将弹性数据插入 Mysql

Insert Elastic Data to Mysql

提问人:user9300309 提问时间:11/16/2023 更新时间:11/16/2023 访问量:23

问:

我在使用 logstash 将数据从 elastic 传输到 mysql 时遇到了问题。我收到错误“无法执行操作 {:action=>LogStash::P ipelineAction::Create/pipeline_id:main, :exception=>”LogStash::ConfigurationError“,”。生成的错误是:

[ERROR][logstash.agent ] Failed to execute action {:action=>LogStash::PipelineAction::Create/pipeline_id:main, :exception=>"LogStash::ConfigurationError", :message=>"Expected one of [^\\r\\n], \"\\r\", \"\\n\" at line 21, column 4 (byte 732) after # }", :backtrace=>["C:/Users/rakesh.s/Documents/ELK/logstash-7.15.0/logstash-core/lib/logstash/compiler.rb:32:in `compile_imperative'", "org/logstash/execution/AbstractPipelineExt.java:187:in `initialize'", "org/logstash/execution/JavaBasePipelineExt.java:72:in `initialize'",

这是我的 Logstash 配置

input {
  elasticsearch {
    hosts => "localhost:9200"
    index => "testrak"
    query => '{"query": { "match_all": {} }}'
    scroll => "5m"
  }
}


output {
  jdbc {
    jdbc_driver_library => "C:/Program Files (x86)/MySQL/Connector J 8.0/mysql-connector-java-8.0.29.jar"
    jdbc_driver_class => "com.mysql.cj.jdbc.Driver"
    jdbc_connection_string => "jdbc:mysql://localhost:3306/elasticdata"
    jdbc_user => "root"
    jdbc_password => ""
    statement => "INSERT INTO elastic_table (id, incident_number, created_on, service_name, ed) VALUES (?, ?, ?, ?, ?)"
    parameters => ["id", "incident_number", "created_on", "service_name", "ed"]
    schedule => "* * * * *"
  }
}

我不知道,这是怎么回事。请提出建议。

mysql elasticsearch jdbc logstash logstash 文件

评论

0赞 Val 11/16/2023
该插件是一个输入插件,但没有输出插件(据我所知),尤其是没有设置的插件。jdbcjdbcschedule
0赞 user9300309 11/16/2023
''' bin\logstash-plugin.bat update logstash-output-jdbc ''' 'output { jdbc { driver_jar_path => “C:/Program Files (x86)/MySQL/Connector J 8.0/mysql-connector-java-8.0.29.jar” connection_string => “jdbc:mysql://localhost:3306;databaseName=elasticdata;user=root;password= “ statement => [”INSERT INTO elastic_table (id, incident_number, created_on, service_name) VALUES (?, ?, ?, ?)“, ”id“, ”incident_number“, ”created_on“, ”service_name“ ] ''' 我在上面添加了
0赞 Val 11/16/2023
您是否正在使用这个插件,这是我发现的唯一一个执行 JDBC 输出的插件(但没有设置,因为它仅在输入上下文中才有意义)?此外,它不再受支持,也不确定它是否适用于 Logstash 7.x。 github.com/theangryangel/logstash-output-jdbcschedule

答: 暂无答案