简体   繁体   English

问题从输入中的logstash连接到弹性搜索

[英]Issue connecting to elastic search from logstash in input

I want to import data from oracle and would like to pass one of the params of the imported data to elastic search to fetch some other details. 我想从oracle导入数据,并希望将导入数据的参数之一传递给弹性搜索以获取其他一些细节。

For ex:- If I have an Employee Id which I get from oracle db for say 100 rows , I want to pass all these 100 employee ids to elastic search and get the emp name and salary. 例如:-如果我有一个从oracle db获得的Employee ID,例如说100行,我想将所有这100个雇员ID传递给弹性搜索,并获取emp名称和薪水。

I am able to retrieve the data from oracle now but unable to connect to elastic search. 我现在能够从oracle检索数据,但无法连接到弹性搜索。 Also I am not sure what will be a better approach to do this. 另外,我不确定哪种方法更好。
I am using log stash 2.3.3 and the elastic search log stash filter plugin. 我正在使用日志存储库2.3.3和弹性搜索日志存储库过滤器插件。

 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 }
   }

I am getting the below error due to elastic search. 由于弹性搜索,出现以下错误。

A plugin had an unrecoverable error. 插件有不可恢复的错误。 Will restart this plugin. 将重新启动此插件。

Plugin: [" 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> 插件:[“ https://xx.corp.com:9200 ”],索引=>“ empdetails”,查询=>“ empId:'1001'”,编解码器=>“ UTF-8”>,scan => true ,大小=> 1000,滚动=>“ 1m”,docinfo => false,docinfo_target =>“ @@ metadata”,docinfo_fields => [“ _ index”,“ _ type”,“ _ id”],ssl => false>

Error: [401] {:level=>:error} 错误:[401] {:level =>:error}

You need to use the elasticsearch filter and not the elasticsearch input 您需要使用elasticsearch过滤器,而不是elasticsearch输入

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"
   }
}
filter {
  elasticsearch {
    hosts => ["xx.corp.com:9200"]
    query => "empId:%{empId}"
    user => "admin"
    password => "admin"
    sort => "empName:desc"
    fields => {
      "empName" => "empName" 
      "salary" => "salary" 
    }
  }
}
output {
  stdout { codec => json_lines }
}

As a result, each record fetched via JDBC will be enriched by the corresponding data found in ES. 结果,通过JDBC提取的每个记录将被ES中的相应数据所丰富。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM