配置文件中添加配置
output {
if [type]=="student" {
elasticsearch {
hosts => "10.130.225.49:9200"
user => elastic
password => elastic
# index名
index => "monitor_student"
# type名
document_type => "_doc"
# 需要关联的数据库中有有一个id字段,对应索引的id号
document_id => "%{id}"
#当id存在的时候会覆盖,当id不存的时候会新增
doc_as_upsert => true
#如果id存在,则覆盖,如果id不存在,则打印一条错误日志(不会影响logstash的运行)
action => "update"
#如果之前_id存在的话,直接抛弃掉新数据。这样的话老数据不会被覆盖。如果_id不存在的话 直接新增。
action => "create"
}
stdout {
codec => json_lines
}
}
}
logstash7.6.2更新已存在的Elasticsearch记录
Warning: A non-numeric value encountered in /data/wangzhan/tech.souyunku.com.wp/wp-content/themes/dux/functions-theme.php on line 1154
赞(89) 打赏
未经允许不得转载:搜云库技术团队 » logstash7.6.2更新已存在的Elasticsearch记录