亲,只收二进制

logstash导入日志数据到elasticsearch如何手动指定_id

Logstash | 作者 zhujw | 发布于2017年08月08日 | 阅读数:11472

我现在有这样一个需求,需要对从logstash导入elasticsearch的数据做update,logstash的elasticsearch-output-plugin 做update需要指定id,所以我想在导入初始数据的时候指定_id,这个_id来自我要导入到ES的一个字段,请问这样可以实现么,谢谢各位(logstash elasticsearch 版本是5.5.0)
已邀请:

novia - 1&0

赞同来自: zhujw laoyang360

output{
elasticsearch{
hosts => "xxx.xxx.xxx.xxx:9200"
flush_size => 100
index => "xxx_log_%{+yyyy.MM.dd}"
document_id => "%{uuid}"
manage_template => true
template_overwrite => true
template_name => "xx-log"
template => "/etc/xxx/template/xx_template.json"
}
stdout{
codec => rubydebug
}
}
document_id即可

netkiller

赞同来自: zhujw 王社英

这样实现
参考这个:https://www.netkiller.cn/datab ... dp125
 
input {
jdbc {
jdbc_driver_library => "/usr/share/java/mysql-connector-java.jar"
jdbc_driver_class => "com.mysql.jdbc.Driver"
jdbc_connection_string => "jdbc:mysql://netkiller:3306/cms"
jdbc_user => "cms"
jdbc_password => ""
schedule => "* * * * *"
statement => "select * from article"
}
}
output {
elasticsearch {
hosts => "netkiller:9200"
index => "information"
document_type => "article"
document_id => "%{id}"

}
}

 
 

laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net

赞同来自:

顶一下!

要回复问题请先登录注册