Logstash Elasticsearch 压缩
Logstash Elasticsearch compression
我有一个有效的 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"
}
}
}
}
}
您需要提供自己的索引模板文件才能启用索引压缩。
因此您需要像这样创建 filebeat-template.json
文件。 logstash 在创建新的 filebeat 索引时将使用此文件。
{
"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-template
的 index template,它会在每次 ES 需要创建一个名称以 filebeat-
开头的新索引时启动,并将应用设置(其中存储压缩一个) 出现在模板中。
我有一个有效的 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"
}
}
}
}
}
您需要提供自己的索引模板文件才能启用索引压缩。
因此您需要像这样创建 filebeat-template.json
文件。 logstash 在创建新的 filebeat 索引时将使用此文件。
{
"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-template
的 index template,它会在每次 ES 需要创建一个名称以 filebeat-
开头的新索引时启动,并将应用设置(其中存储压缩一个) 出现在模板中。