【问题标题】:Elasticsearch Field limit more than 1000Elasticsearch 字段限制超过 1000
【发布时间】:2018-10-04 18:13:51
【问题描述】:

有人可以帮忙吗?我需要修复错误,以便可以将 S3 中的 CloudTrail 日志发送到 ES 的 Logstash 并在 Kibana 中查看。无法弄清楚如何将字段限制增加到更高的值。我的配置看起来像

input {
   s3 {
     bucket => "sample-s3bucket"
     region => "eu-west-1"
     type => "cloudtrail"
     codec => cloudtrail {}
     sincedb_path => "/tmp/logstash/cloudtrail"
     exclude_pattern => "/CloudTrail-Digest/"
     interval => 300
   }
}

filter {
    if [type] == "cloudtrail" {
        json {
            source => "message"
        }

        geoip {
            source => "sourceIPAddress"
            target => "geoip"
            add_tag => ["cloudtrail-geoip"]
        }
    }
}

output {
    elasticsearch {
      hosts => "coordinate_node:9200"
      index => 'cloudtrail-%{+YYYY.MM.dd}'
         }
    stdout {
     codec => rubydebug
    }
 }

这是在我的 Logstash 机器上看到的关于 limit 的内容

2018-10-04T17:49:49,883][WARN][logstash.outputs.elasticsearch] 无法将事件索引到 Elasticsearch。 {:status=>400, :action=>["index", {:_id=>nil, :_index=>"cloudtrail-2018.09.27", :_type=>"doc", :_routing=>nil}, #], :response=>{"index"=>{"_index"=>"cloudtrail-2018.09.27", "_type"=>"doc", "_id"=>"lrMzQGYBOny1_iySNW6G", "status"=> 400, "error"=>{"type"=>"illegal_argument_exception", "reason"=>"已超出索引 [cloudtrail-2018.09.27] 中总字段 [1000] 的限制"}}}

提前致谢

【问题讨论】:

    标签: elasticsearch logstash geoip kibana-6 amazon-cloudtrail


    【解决方案1】:
    1. 您必须在集群上设置index template

    您可以使用以下模板来设置添加到集群中的所有索引的设置。一旦你通过 logstash 建立索引,下面的模板会将所有创建的索引的字段限制设置为 2000。

    PUT /_template/Global
    {
        "index_patterns" : ["*"],
        "order" : 0,
        "settings" : {
            "index.mapping.total_fields.limit" : "2000"
        }        
    }
    

    注意:如果您想使用特定索引的设置,可以将模式更改为"index_patterns" : ["cloudtrail-*"]

    1. 另一种选择是使用logstash template as explained on this link

    当一个文档中的字段数量如此之多时,您还应该考虑重新构建文档映射,而不是响应中总是需要所有字段。考虑创建诸如 Join/parent-child 等关系以创建更小的文档以提高效率。

    【讨论】:

    • 谢谢@theuknown,按照你的第二个建议,它完成了工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-02
    • 2021-01-16
    • 1970-01-01
    • 1970-01-01
    • 2017-12-26
    • 2023-03-07
    相关资源
    最近更新 更多