【发布时间】:2016-09-07 08:22:49
【问题描述】:
我想从 oracle 导入数据,并想将导入数据的参数之一传递给弹性搜索以获取其他一些详细信息。
例如:- 如果我有一个从 oracle db 获得的员工 ID,比如 100 行,我想将所有这 100 个员工 ID 传递给弹性搜索并获取员工姓名和薪水。
我现在可以从 oracle 检索数据,但无法连接到弹性搜索。我也不确定什么是更好的方法来做到这一点。
我正在使用 log stash 2.3.3 和 elastic search log stash filter 插件。
input {
jdbc {
jdbc_connection_string => "jdbc:oracle:thin:@<dbhost>:<port>:<sid>"
# The user we wish to execute our statement as
jdbc_user => “user"
jdbc_password => “pass"
# The path to our downloaded jdbc driver
jdbc_driver_library => “<path>"
# The name of the driver class for oracle
jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
# our query
statement => "SELECT empId, desg from Employee"
}
elasticsearch {
hosts => "https://xx.corp.com:9200"
index => “empdetails”
}
}
output {
stdout { codec => json_lines }
}
由于弹性搜索,我收到以下错误。
插件出现不可恢复的错误。将重新启动此插件。
插件:["https://xx.corp.com:9200"], index=>"empdetails", query=>”empId:'1001'", codec=>"UTF-8">, scan=>true, size=>1000 , scroll=>"1m", docinfo=>false, docinfo_target=>"@metadata", docinfo_fields=>["_index", "_type", "_id"], ssl=>false>
错误:[401] {:level=>:error}
【问题讨论】:
-
我可以修复上述错误,现在我可以从弹性搜索中获取数据。但是任何人仍然可以给我任何关于如何从 jdbc 传递数据并从弹性搜索中获取相应数据的指针。我对记录 stash 非常陌生,因此非常感谢任何信息。
-
更新代码如下 - elasticsearch { ssl => true hosts => "xx.corp.com:9200" index => "empdetails" query => '{ "query": { "match ": { "empId": "1001" } } }' 用户 => "admin" 密码 => "admin" }