2016-04-29 110 views
1

我有一個工作ELK堆棧,並希望啓用索引壓縮。Logstash Elasticsearch壓縮

官方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" 
     } 
     } 
    } 
    } 
} 
+0

您使用的是哪個版本的logstash? – Val

+0

Logstash 2.3,Elasticsearch 2.3 –

回答

4

您需要提供自己的索引模板文件才能啓用索引壓縮。

所以你需要創建你的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-開頭的新索引時,它將應用模板中存在的設置(其中存儲壓縮一個)。

+0

哦,我不知道elasticsearch模板。現在測試這個謝謝! –

+0

全面運作,謝謝! –

+0

真棒,很高興它解決了! – Val