Elasticsearch best_compression 不工作

Elasticsearch best_compression is not working

我正在从 Logstash 解析 Apache 访问日志并将其索引到 Elasticsearch 索引中。我还索引了 geoipagent 字段。在索引时我观察到 elasticsearch 索引大小 6.7x 大于实际文件大小(space 在磁盘上)。所以我只想了解这是正确的行为还是我在这里做错了什么?我正在使用 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 索引大小?

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

在下面的示例中,我使用了索引名称 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