【问题标题】:Logstash Elasticsearch compressionLogstash Elasticsearch 压缩
【发布时间】:2016-04-29 16:28:39
【问题描述】:

我有一个可用的 ELK 堆栈,并希望启用索引压缩。

官方store compression documentation 告诉我需要在创建索引时进行。

我在相关的logstash output documentation 中找不到与存储压缩甚至索引设置相关的任何内容

下面是我的logstash输出配置:

output {
  elasticsearch {
    hosts => [ "localhost:9200" ]
    sniffing => true
    manage_template => false
    index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
    document_type => "%{[@metadata][type]}"
  }
}

以及创建的索引设置:

{
  "filebeat-2016.04.28": {
    "settings": {
      "index": {
        "creation_date": "1461915752875",
        "uuid": "co8bvXI7RFKFwB7oJqs8cA",
        "number_of_replicas": "1",
        "number_of_shards": "5",
        "version": {
          "created": "2030199"
        }
      }
    }
  }
}

【问题讨论】:

  • 您使用的是哪个版本的logstash?
  • Logstash 2.3、Elasticsearch 2.3

标签: elasticsearch logstash elastic-stack


【解决方案1】:

您需要提供自己的索引模板文件才能启用索引压缩。

所以你需要像这样创建你的filebeat-template.json 文件。在创建新的 filebeat 索引时,logstash 将使用此文件。

{
  "template" : "filebeat-*",
  "settings" : {
    "index.codec" : "best_compression"
  }
}

那么你的elasticsearch 输出应该这样修改:

output {
  elasticsearch {
    hosts => [ "localhost:9200" ]
    sniffing => true
    index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
    document_type => "%{[@metadata][type]}"
    template_name => "filebeat-template"
    template => "/path/to/filebeat-template.json"
  }
}

然后您可以删除现有的filebeat-2016.04.28 索引并重新启动logstash。后者将创建一个名为/_template/filebeat-templateindex template,它将在每次ES 需要创建一个名称以filebeat- 开头的新索引时启动,并且它将应用模板中存在的设置(其中包括存储压缩)。

【讨论】:

  • 哦,我不知道弹性搜索模板。立即测试,谢谢!
猜你喜欢
  • 1970-01-01
  • 2019-09-07
  • 1970-01-01
  • 2012-12-26
  • 1970-01-01
  • 1970-01-01
  • 2017-03-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多