适用场景

  • 获取日志本身时间
  • 日志时间转Unix时间
  • 重组message

示例日志:

hellow@,@world@,@2011-11-01 18:46:43

logstash 配置文件:

input{ stdin{} }

filter{ grok{
        match =>{"message"=>"%{WORD:s1}@,@%{WORD:s2}@,@%{TIMESTAMP_ISO8601:t1}"}
        remove_field => "message"
	  }
       date{match=>["t1","YYYY-MM-dd HH:mm:ss"]
            target=>"logdate"}
ruby {
    code => "
             event['logdateunix'] = event['logdate'].to_i
             event['yourmsg']=event['logdate'].to_s+event['s1']+event['s2']
            " # combine fields you want in yourmsg Note the tyoe conversion
	 }
}
output{ stdout{codec => rubydebug} }

输出结果:

Logstash时区、时间转换,message重组

相关文章:

  • 2021-12-05
  • 2022-12-23
  • 2022-01-26
  • 2021-08-04
  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
  • 2021-12-30
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
相关资源
相似解决方案