我正在尝试使用elasticsearch + logstash(jdbc输入)。
我的弹性搜索似乎没问题。问题似乎是在logstash(elasticsearch输出插件)中。
我的logstash.conf:
input {
jdbc {
jdbc_driver_library => "C:\DEV\elasticsearch-1.7.1\plugins\elasticsearch-jdbc-1.7.1.0\lib\sqljdbc4.jar"
jdbc_driver_class => "com.microsoft.sqlserver.jdbc.SQLServerDriver"
jdbc_connection_string => "jdbc:sqlserver://localhost:1433;databaseName=dbTest"
jdbc_user => "user"
jdbc_password => "pass"
schedule => "* * * * *"
statement => "SELECT ID_RECARGA as _id FROM RECARGA where DT_RECARGA >= '2015-09-04'"
jdbc_paging_enabled => "true"
jdbc_page_size => "50000"
}
}
filter {
}
output {
elasticsearch {
host => "localhost"
protocol => "http"
index => "test_index"
document_id => "%{objectId}"
}
stdout { codec => rubydebug }
}
当我运行日志存储时:
C:\DEV\logstash-1.5.4\bin>logstash -f logstash.conf
我得到了这个结果:
←[33mfailed action with response of 400, dropping action: ["index", {:_id=>"%{ob
jectId}", :_index=>"parrudo", :_type=>"logs", :_routing=>nil}, #<LogStash::Event
:0x5d4c2abf @metadata_accessors=#<LogStash::Util::Accessors:0x900a6e7 @store={"r
etry_count"=>0}, @lut={}>, @cancelled=false, @data={"_id"=>908026, "@version"=>"
1", "@timestamp"=>"2015-09-04T21:19:00.322Z"}, @metadata={"retry_count"=>0}, @ac
cessors=#<LogStash::Util::Accessors:0x4929c6a4 @store={"_id"=>908026, "@version"
=>"1", "@timestamp"=>"2015-09-04T21:19:00.322Z"}, @lut={"type"=>[{"_id"=>908026,
"@version"=>"1", "@timestamp"=>"2015-09-04T21:19:00.322Z"}, "type"], "objectId"
=>[{"_id"=>908026, "@version"=>"1", "@timestamp"=>"2015-09-04T21:19:00.322Z"}, "
objectId"]}>>] {:level=>:warn}←[0m
{
"_id" => 908026,
"@version" => "1",
"@timestamp" => "2015-09-04T21:19:00.322Z"
}
{
"_id" => 908027,
"@version" => "1",
"@timestamp" => "2015-09-04T21:19:00.322Z"
}
{
"_id" => 908028,
"@version" => "1",
"@timestamp" => "2015-09-04T21:19:00.323Z"
}
{
"_id" => 908029,
"@version" => "1",
"@timestamp" => "2015-09-04T21:19:00.323Z"
}
在elasticsearch中,索引已创建,但有任何文档。
我正在使用Windows和MSSql Server。
elasticsearch版本:1.7.1 logstash版本:1.5.4 任何想法?
谢谢!
答案 0 :(得分:0)
好吧......在弹性搜索日志中查看这个错误后,我意识到问题是我的sql语句中的别名。
statement =&gt; “选择ID_RECARGA为_id FROM RECARGA,其中DT_RECARGA&gt; ='2015-09-04'”
由于某些原因,我不知道它没有被处理,所以我只是从我的查询中删除它,现在一切似乎都正确。
谢谢!