elk常用知识点

1、让文件每次都从头读取:

   当有时候需要重新抽取全日志时候,则需要先删除ES上的索引,然后在logstash上input插件配置sincedb_path => "/dev/null" 表示logstash在每次重启之后

 都重新开始记录日志位置,日志记录从头开始。

  input

       { file

                 {    path => ["/data/test.log"]

                      start_position => "beginning"

                      sincedb_path => "/dev/null"

                 }

        }

 2、 处理中文输入ES显示乱码问题:

 有些开发人员在打印日志的时候,将日志输出进行了字符集规定;如设置为GBK等;而此时操作系统的字符集如果设置为en_us.utf-8,则会出现日志在操作系统显示为乱码,当进行日志文件查看时,需要将连接工作xshell设置成 和日志输出字符集GBK模式,则日志输出在windows下则会显示 正常中文,否则乱码,而此时通过xshell进行编辑时,则会显示乱码(因为VIM操作是操作系统显示,输出字符集采用的是操作系统的字符集LANG ,此时则需要修改LANG为中文字符集,#export LANG=Zh_Cn.GBK),进行vim则会显示正常中文

 logstash做日志收集时,如果遇上述问题,则需要再input插件中修改字符集:

input {
file {
path => ["/xxx/xx/log/c_disorder_qutrz.log"]
type => "datetime"
start_position => "beginning"
# codec => plain{ charset => "GBK" }
}
file {
path => ["/xxx/xxx/log/als_gci.log"]
type => "dark"
start_position => "beginning"
# codec => plain{ charset => "GBK" }
}

}

 

posted @ 2018-05-10 16:11  xiao_pai_pai  阅读(408)  评论(0编辑  收藏  举报