簡體   English   中英

Logstash:從一個彈性搜索遷移到另一個彈性搜索會導致一些附加屬性

[英]Logstash: Migrating from one elastic search to another elastic search result in some additional properties

我一直在使用 Logstash 將其中一個索引從自托管 Elasticsearch 遷移到 Amazon ElasticSearch。 成功遷移后,我們發現文檔中添加了一些額外的字段。 我們如何防止它被添加

我們的 Logstash 配置文件

input {
 elasticsearch {
 hosts => ["https://staing-example.com:443"]
 user => "userName"
 password => "password"
 index => "testingindex"
 size => 100
 scroll => "1m"
 }
}

filter {

}

output {
 amazon_es {
 hosts => ["https://example.us-east-1.es.amazonaws.com:443"]
 region => "us-east-1"
 aws_access_key_id => "access_key_id"
 aws_secret_access_key => "access_key_id"
 index => "testingindex"
}
stdout{
  codec => rubydebug
  }
}

我們自托管 ElasticSearch 中的文檔

{
        "_index": "testingindex",
        "_type": "interaction-3",
        "_id": "38b23e7a-eafd-4163-a9f0-e2d9ffd5d2cf",
        "_score": 1,
        "_source": {
           "customerId" : [
            "e177c1f8-1fbd-4b2e-82b8-760536e42742"
          ],
          "customProperty" : {
            "messageFrom" : [
              "BOT"
            ]
          },
          "userId" : [
            "e177c1f8-1fbd-4b2e-82b8-760536e42742"
          ],
          "uniqueIdentifier" : "2b027fc0-a517-49a7-a71f-8732044cb249",
          "accountId" : "724bee3e-38f8-4538-b944-f3e21c518437"
        }
      }

我們的 Amazon ElasticSearch 中的文檔

   {
        "_index" : "testingindex",
        "_type" : "doc",
        "_id" : "B-hP020Bd2lcvg9lTyBH",
        "_score" : 1.0,
        "_source" : {
          "customerId" : [
            "e177c1f8-1fbd-4b2e-82b8-760536e42742"
          ],
          "customProperty" : {
            "messageFrom" : [
              "BOT"
            ]
          },
          "@version" : "1",
          "userId" : [
            "e177c1f8-1fbd-4b2e-82b8-760536e42742"
          ],
          "@timestamp" : "2019-10-16T06:44:13.154Z",
          "uniqueIdentifier" : "2b027fc0-a517-49a7-a71f-8732044cb249",
          "accountId" : "724bee3e-38f8-4538-b944-f3e21c518437"
        }
      }

@Version 和 @Timestamp 是文檔中新添加的兩個字段

誰能解釋為什么要添加它是否有其他方法可以防止這種情況發生? 當您比較兩個文檔時, _type_id也發生了變化,我們需要_type_id與我們在自托管 Elasticsearch 中的文檔相同

@version@timestamp字段由 logstash 生成,如果您不想要它們,則需要使用 mutate 過濾器來刪除。

mutate {
    remove_fields => ["@version","@timestamp"]
}

要保留原始文檔的_type_id ,您需要更改輸入並添加選項docinfo => true以將這些字段放入@metadata字段並在 output 中使用它們, 文檔中有一個示例。

input {
    elasticsearch {
        ...
        docinfo => true
    }

output {
    elasticsearch {
        ...
        document_type => "%{[@metadata][_type]}"
        document_id => "%{[@metadata][_id]}"
    }
}

請注意,如果您的 Amazon Elasticsearch 版本為 6.X 或更高版本,則每個索引只能有一種文檔類型,並且版本 7.X 是無類型的,此外, logstash版本 7.X 不再具有document_type選項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM