我正在尝试使用变化 Logstash插件来检测我的CouchDB更改并充分更新Elasticsearch索引。
文档创建/更新工作正常,但删除不起作用。
下面是我的Logstash配置:
input {
couchdb_changes {
host => "localhost"
db => "products"
sequence_path => ".couchdb_products_seq"
type => "product"
tags => ["product"]
keep_revision => true
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "products"
# Pass the CouchDB document ID to Elastic, otherwise it is lost and Elastic generates a new one
document_id => "%{[@metadata][_id]}"
}
# Debug
stdout {
codec => rubydebug {
metadata => true
}
}
}我遇到了此链接,但是“协议”参数在弹性搜索 Logstash插件中已经不存在了,而且我希望到现在为止已经修复了这样一个巨大的bug。
在我的Logstash控制台中,当我删除一个CouchDB文档(从富顿)时,我看到了这一点:
{
"@version" => "1",
"@timestamp" => "2016-05-13T14:06:55.734Z",
"type" => "product",
"tags" => [
[0] "product"
],
"@metadata" => {
"_id" => "15d6f519d6827a2f28de4df1d40082d5",
"action" => "delete",
"seq" => 10020
}
}因此,它没有删除id为"15d6f519d6827a2f28de4df1d40082d5“的文档,而是替换了其内容。以下是删除后的文件"15d6f519d6827a2f28de4df1d40082d5“,在Elasticsearch中:
curl -XGET 'localhost:9200/products/product/15d6f519d6827a2f28de4df1d40082d5?pretty'
{
"_index" : "products",
"_type" : "product",
"_id" : "15d6f519d6827a2f28de4df1d40082d5",
"_version" : 3,
"found" : true,
"_source" : {
"@version" : "1",
"@timestamp" : "2016-05-13T14:06:55.734Z",
"type" : "product",
"tags" : [ "product" ]
}
}知道为什么删除不起作用吗?这是couchdb_changes插件的错误吗?elasticsearch插件?
有关信息,以下是我的应用版本:ElasticSearch2.3.2Logstash2.3.2ApacheApache1.6.1
发布于 2016-05-17 09:14:50
我想我找到问题了。我不得不在logstash output.elasticsearch配置中手动添加这一行:
action => "%{[@metadata][action]}"以便将元数据中的“删除”传递给Elasticsearch。
现在重新插入还有另一个问题,但是它在GitHub票中被跟踪。
编辑:为了绕过这个问题,我实际上更改了我的配置(主要是添加一个字段来存储该操作是否是delete):
input {
couchdb_changes {
host => "localhost"
db => "products"
sequence_path => ".couchdb_products_seq"
type => "product"
tags => ["product"]
keep_revision => true
}
}
filter {
if [@metadata][action] == "delete" {
mutate {
add_field => { "elastic_action" => "delete" }
}
} else {
mutate {
add_field => { "elastic_action" => "index" }
}
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "products"
document_id => "%{[@metadata][_id]}"
action => "%{elastic_action}"
}
# Debug
stdout {
codec => rubydebug {
metadata => true
}
}
}我在Logstash/Elasticsearch方面还远不及专家,但这似乎是暂时可行的。
https://stackoverflow.com/questions/37212726
复制相似问题