gpt4 book ai didi

json - logstash 提取 json 字段并覆盖索引

转载 作者:行者123 更新时间:2023-12-03 01:38:44 29 4
gpt4 key购买 nike

我有以下json:

[
{
"key": "Key-1",
"field1": "hello",
"field2": "world"
},
{

"key": "Key-2",
"field1": "hello",
"field2": "world"
}
]

和以下logstash文件:
input {
http_poller {
# List of urls to hit
# URLs can either have a simple format for a get request
# Or use more complex HTTP features
urls => {
myurl => {
method => "GET"
url => "http://localhost:8080/helloworld"
}
}
# Decode the results as JSON
codec => "json"
# Schedule task
schedule => { cron => "* * * * * UTC" }
}

}

output {
#debugging output

stdout {
codec => rubydebug
}

# elasticsearch output

elasticsearch{
hosts => "localhost"
index => "helloworld"
}

}

问题是这个logstash创建了多个具有相同键的文档,我希望logstash替换索引中的现有文档。反正我能做到吗?
提前致谢。

最佳答案

您应该定义文档的 id 是什么,以便您可以根据 key 更新现有的。

elasticsearch {
document_id => "%{key}"
hosts => "localhost"
index => "helloworld"
}

请参阅文档 here了解更多信息。

关于json - logstash 提取 json 字段并覆盖索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49926104/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com