博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Create rolling monthly, weekly and daily Logstash indices
阅读量:5825 次
发布时间:2019-06-18

本文共 2413 字,大约阅读时间需要 8 分钟。

在刚刚开始接触ELK的时候我们习惯把每一个index都按照day来切割。但是我们会发现我们的shards 会很多。

其实我们一该把那些小的index按照一周或者一个月来rolling,来减少我们的shards数。

我使用的是logstash5,这里我们每启动一个logstash的进程的时候我们会发现我们的jvm 参数的-Xmx1g -Xms1g

但是我么一些可以设置小一点,比如512m 甚至是256m 来减少资源分配

具体的操作方案:

原文来自于:http://www.atechref.com/blog/elk/elk-stack-logstash-mutate-and-monthly-index-setting/How often should a new log index be created? Once a day, Once a week, Once a month? A simple search in Google would return various responses each arguing the pros and cons of creating indexes daily or weekly. Lets look at how to do that with logstash.My take on that is “once a month” index is the best option.  The following is my reasoning for this.Pros:Easier back up with a monthly indexSimple to create snapshots and restoreOne index to backup externally on NAS or other storage outside of ELK stackWorks well where the retention policy for active logs is 30 days or 60 days etcAllows complete logs for the whole month to be restored in one go.Cons: Potential for large index sizesHave to restore the whole index to search for a specific day of the monthBackup and restore of these indexes can take some time in slower systems or single node instancesCreating a monthly rolling index fileIn order to create a new index each month automatically ensure you have the following setting in your logstash config file for e.g. devlogstash.conf.input{  ….  }  filter{   ….  }  output{elasticsearch{            hosts => [“192.168.0.1:9200”]            index => “dev-logstash-%{+YYYY.MM}”}}Creating a weekly rolling index fileThe weekly name format would be YYYY.ww as in 2017.01 for the first week of the year in number.  Config setting would be as shown below.input{  ….  }  filter{   ….  }  output{elasticsearch{            hosts => [“192.168.0.1:9200”]             index => “dev-logstash-%{+YYYY.ww}”}}Creating a daily rolling index fileJust add MM.DD instead of WW to the setting above to create a daily rolling index as shown below.input{  ….  }  filter{   ….  }  output{elasticsearch{         hosts => [“192.168.0.1:9200”]         index => “dev-logstash-%{+YYYY.MM.DD}”}}Creating a Year, month and week rolling index fileAnd that could be defined as YYYY.MM.ww to create a weekly rolling index as shown below.input{  ….  }  filter{   ….  }  output{elasticsearch{         hosts => [“192.168.0.1:9200”]         index => “dev-logstash-%{+YYYY.MM.ww}”}} Restart logstash for these changes to take effect.

 

转载地址:http://vdsdx.baihongyu.com/

你可能感兴趣的文章
统治世界的十大算法
查看>>
linux svn安装和配置
查看>>
SSH中调用另一action的方法(chain,redirect)
查看>>
数据库基础
查看>>
表格排序
查看>>
关于Android四大组件的学习总结
查看>>
java只能的round,ceil,floor方法的使用
查看>>
由于无法创建应用程序域,因此未能执行请求。错误: 0x80070002 系统找不到指定的文件...
查看>>
新开的博客,为自己祝贺一下
查看>>
【CQOI2011】放棋子
查看>>
采用JXL包进行EXCEL数据写入操作
查看>>
一周总结
查看>>
将txt文件转化为json进行操作
查看>>
线性表4 - 数据结构和算法09
查看>>
C语言数据类型char
查看>>
Online Patching--EBS R12.2最大的改进
查看>>
Binary Search Tree Iterator leetcode
查看>>
uva-317-找规律
查看>>
Event事件的兼容性(转)
查看>>
我的2014-相对奢侈的生活
查看>>