JDBC logstash弹性基巴纳

发布于 2025-02-07 11:22:09 字数 989 浏览 1 评论 0原文

我正在使用JDBC输入插件从MongoDB摄入到Elasticsearch的数据中。 我的配置是:

`input {
  jdbc {
    jdbc_driver_class => "mongodb.jdbc.MongoDriver"
    jdbc_driver_library => "/usr/share/logstash/logstash-core/lib/jars/mongodb_unityjdbc_free.jar"
    jdbc_user => ""
    jdbc_password => ""
    jdbc_connection_string => "jdbc:mongodb://localhost:27017/pritunl"
    schedule => "* * * * *"
    jdbc_page_size => 100000
    jdbc_paging_enabled => true
    statement => "select * from servers_output"
  }
}
filter {
mutate {
copy => { "_id" => "[@metadata][id]"}
remove_field => ["_id"]
}
}
output {

     elasticsearch {
        hosts => "localhost:9200"
        index => "pritunl"
        document_id => "%{[@metadata][_id]}"
}
        stdout {}
}`

在Kibana中,我只看到一个命中在此处输入image Descriage ,但是在Stdout I中请参阅MongoDB Collection的许多记录。我应该怎么做,看到他们全部?

I'm using JDBC input plugin to ingest data from mongodb to ElasticSearch.
My config is:

`input {
  jdbc {
    jdbc_driver_class => "mongodb.jdbc.MongoDriver"
    jdbc_driver_library => "/usr/share/logstash/logstash-core/lib/jars/mongodb_unityjdbc_free.jar"
    jdbc_user => ""
    jdbc_password => ""
    jdbc_connection_string => "jdbc:mongodb://localhost:27017/pritunl"
    schedule => "* * * * *"
    jdbc_page_size => 100000
    jdbc_paging_enabled => true
    statement => "select * from servers_output"
  }
}
filter {
mutate {
copy => { "_id" => "[@metadata][id]"}
remove_field => ["_id"]
}
}
output {

     elasticsearch {
        hosts => "localhost:9200"
        index => "pritunl"
        document_id => "%{[@metadata][_id]}"
}
        stdout {}
}`

In Kibana I see only one hitenter image description here, but in stdout I see many records from mongodb collection. What should I do, to see them all?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

盛装女皇 2025-02-14 11:22:09

问题是,您所有的文档都以相同的“ _id”保存,因此,即使您向ES发送不同的记录,也只有一个文档在内部被覆盖 - 因此您在Kibana中获得了1次命中。

您的配置中有一个错别字来引起此问题。

您正在将“ _id”复制到“ [@metadata] [ id ]”中,

但您正在尝试阅读“ [@metadata] [ _id ]” 。

阅读Document_ID值时,请删除下划线,应解决您的问题。

output {
  elasticsearch {
    hosts => "localhost:9200"
    index => "pritunl"
    document_id => "%{[@metadata][id]}"
  }
  stdout {}
}`

The problem is, that all your documents are saved with the same "_id", so even though you're sending different records to ES, only one document is being overwritten internally - thus you get 1 hit in Kibana.

There is a typo in your configuration to cause this issue.

You're copying "_id" into "[@metadata][id]"

But you're trying to read "[@metadata][_id]" with an underscore.

Removing the underscore when reading the value for document_id should fix your issue.

output {
  elasticsearch {
    hosts => "localhost:9200"
    index => "pritunl"
    document_id => "%{[@metadata][id]}"
  }
  stdout {}
}`
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文