加入收藏 | 设为首页 | 会员中心 | 我要投稿 云计算网_泰州站长网 (http://www.0523zz.com/)- 视觉智能、AI应用、CDN、行业物联网、智能数字人!
当前位置: 首页 > 服务器 > 搭建环境 > Windows > 正文

你头疼的ELK难题,本文几乎都解决了

发布时间:2019-03-22 21:38:18 所属栏目:Windows 来源:alonghub
导读:副标题#e# 一、ELK实用知识点总结 1、编码转换问题 这个问题,主要就是中文乱码。 input中的codec=plain转码: codec=plain{ charset=GB2312 } 将GB2312的文本编码,转为UTF-8的编码。 也可以在filebeat中实现编码的转换(推荐): filebeat.prospectors: -in

②logstash grok对合并后多行的处理。合并多行后续都一样,如下:

  1. filter { 
  2. grok { 
  3. match => { 
  4. "message" => "^%{TIMESTAMP_ISO8601:InsertTime} .*- task request,.*,start time:%{TIMESTAMP_ISO8601:RequestTime}n-- Request String : {"UserName":"%{NUMBER:UserName:int}","Pwd":"(?<Pwd>.*)","DeviceType":%{NUMBER:DeviceType:int},"DeviceId":"(?<DeviceId>.*)","EquipmentNo":(?<EquipmentNo>.*),"SSID":(?<SSID>.*),"RegisterPhones":(?<RegisterPhones>.*),"AppKey":"(?<AppKey>.*)","Version":"(?<Version>.*)"} -- Endn-- Response String : {"ErrorCode":%{NUMBER:ErrorCode:int},"Success":(?<Success>[a-z]*),"ErrorMsg":(?<ErrorMsg>.*),"Result":(?<Result>.*),"WaitInterval":%{NUMBER:WaitInterval:int}} -- End" 

在filebeat中使用multiline插件(推荐):

①介绍multiline

  • pattern:正则匹配从哪行合并;
  • negate:true/false,匹配到pattern 部分开始合并,还是不配到的合并。

match:after/before(需自己理解)

  • after:匹配到pattern 部分后合并,注意:这种情况最后一行日志不会被匹配处理;
  • before:匹配到pattern 部分前合并(推荐)。

②5.5版本之后(before为例)

  1. filebeat.prospectors: 
  2. - input_type: log 
  3.   paths: 
  4.     - /root/performanceTrace* 
  5.   fields: 
  6.     type: zidonghualog 
  7.   multiline.pattern: '.*"WaitInterval":.*-- End' 
  8.   multiline.negate: true 
  9.   multiline.match: before 

③5.5版本之前(after为例)

  1. filebeat.prospectors: 
  2. - input_type: log  
  3.      paths: 
  4.       - /root/performanceTrace* 
  5.       input_type: log  
  6.       multiline: 
  7.            pattern: '^20.*' 
  8.            negate: true 
  9.            match: after 

在logstash input中使用multiline插件(没有filebeat时推荐):

①介绍multiline

  • pattern:正则匹配从哪行合并;
  • negate:true/false,匹配到pattern 部分开始合并,还是不配到的合并。

what:previous/next(需自己理解)

  • previous:相当于filebeat 的after;
  • next:相当于filebeat 的before。

②用法

  1. input { 
  2.         file { 
  3.                 path => ["/root/logs/log2"] 
  4.                 start_position => "beginning" 
  5.                 codec => multiline { 
  6.                         pattern => "^20.*" 
  7.                         negate => true 
  8.                         what => "previous" 
  9.                 } 
  10.         } 

在logstash filter中使用multiline插件(不推荐):

(编辑:云计算网_泰州站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读