gpt4 book ai didi

mongodb - 使用 Logstash 将数据从 mongoDB 同步到 elasticsearch

转载 作者:行者123 更新时间:2023-12-03 02:26:58 26 4
gpt4 key购买 nike

我正在尝试将 mongoDB 数据库同步到 elasticsearch。我正在使用 logstash-input-mongoDblogstash-output-elasticsearch插件。

问题是 mongoDb 插件无法从 mongodb 中插入的文档中提取所有信息,因此我看到只有很少的字段被插入到 elasticsearch 中。而且我还将整个查询作为 elasticsearch 索引中的日志。我试图在 logstash 的配置文件中操作过滤器并将输入更改为 elasticsearch 但无法使其工作。

任何帮助或建议都会很棒。



编辑:
Mongo 架构:

A:{
B: 'sometext',
C: {G: 'someText', H:'some text'}
},
D:[
{E:'sometext',F:'sometext'},
{E:'sometext',F:'sometext'},
{E:'sometext',F:'sometext'}
]

插件:

    input {
mongodb {
uri => 'mongodb://localhost:27017/testDB'
placeholder_db_dir => '/opt/logstash-mongodb/'
placeholder_db_name => 'logstash_sqlite.db'
collection => 'testCOllection'
batch_size => 1000
}
}
output {
stdout {
codec => rubydebug
}
elasticsearch {
action => "index"
index => "testdb_testColl"
hosts => ["localhost:9200"]
}
}

输出到弹性:

{
//some metadata
A_B: 'sometext',
A_C_G: 'someText',
A_C_H: 'some text',
log_entry: 'contains complete document inserted to mongoDB'
}

我们没有在 elastic 中获取 mongo 集合的属性 D。希望这能更详细地解释问题。

最佳答案

因为你的配置对我来说很好,我检查了 phutchins/logstash-input-mongodb 存储库的问题,我发现了这个:“array not stored to elasticsearch”,它几乎描述了你的问题。这仍然是一个悬而未决的问题,但您可能想尝试一下 the workaround suggested by ivancruzbht .这种解决方法使用 ruby Logstash 过滤器来解析 log_entry 字段,您还确认该字段具有所有字段 - 包括 D

关于mongodb - 使用 Logstash 将数据从 mongoDB 同步到 elasticsearch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60864512/

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