【问题标题】:Elasticsearch best_compression is not workingElasticsearch best_compression 不起作用
【发布时间】:2016-11-25 12:57:11
【问题描述】:

我正在解析来自 Logstash 的 Apache 访问日志并将其索引到 Elasticsearch 索引中。我还索引了geoipagent 字段。索引时我观察到elasticsearch 索引大小6.7x 大于实际文件大小(磁盘空间)。所以我只想了解这是正确的行为还是我在这里做错了什么?我正在使用Elasticsearch 5.0Logstash 5.0Kibana 5.0 版本。我也试过best_compression,但它占用了相同的磁盘大小。这是迄今为止我尝试过的配置文件的完整观察。

我的观察:

用例 1:

Apache Log file Size:211 MB
Total number of lines:1,000,000
Index Size:1.5 GB
Observation:索引为6.7x,大于文件大小。

用例 2:

我找到了一些压缩elasticsearch索引的解决方案,然后我也尝试了。

- Disable `_all` fields
- Remove unwanted fields that has been created by `geoip` and `agent` parsing.
- Enable `best_compression` [ index.codec": "best_compression"]

Apache Log file Size: 211 MB
Total number of lines: 1,000,000
Index Size: 1.3 GB
Observation: 索引是6.16x 大于文件大小

日志文件格式:

127.0.0.1 - - [24/Nov/2016:02:03:08 -0800] "GET /wp-admin HTTP/1.0" 200 4916 "http://trujillo-carpenter.com/" "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 5.01; Trident/5.1)"

我发现 Logstash + Elasticsearch Storage Experients 他们说他们已将索引大小从 6.23x 减小到 1.57x。但这是相当老的解决方案,这些解决方案在 Elasticsearch 5.0 中不再有效。

我已经尝试过的更多参考:
- Part 2.0: The true story behind Elasticsearch storage requirements
- https://github.com/elastic/elk-index-size-tests

当您的目的只是在 Kibana 上显示可视化时,有没有更好的方法来优化 Elasticseach 索引大小?

【问题讨论】:

    标签: elasticsearch logstash kibana


    【解决方案1】:

    由于索引设置未应用于索引,我遇到了这个问题。我的索引名称和模板名称不同。使用相同的模板名称和索引名称压缩后应用正确。

    在下面的示例中,我使用了索引名称 apache_access_logs 和模板名称 elk_workshop

    共享更正后的模板和 logstash 配置。

    Logstash.conf

    output {
      elasticsearch {
        hosts => ["localhost:9200"]
        index => "apache_access_logs"
        template => "apache_sizing_2.json"
        template_name => "apache_access_logs" /* it was elk_workshop */
        template_overwrite => true
      }
    }
    

    模板:

    {
    
        "template": "apache_access_logs", /* it was elk_workshop */
        "settings": {
            "index.refresh_interval": "5s",
            "index.refresh_interval": "30s",
            "number_of_shards": 5,
            "number_of_replicas": 0
        },
        ..
    }         
    

    参考:https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templates.html#indices-templates

    【讨论】:

      猜你喜欢
      • 2015-12-24
      • 2018-03-11
      • 1970-01-01
      • 1970-01-01
      • 2011-09-07
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多