当前位置:网站首页>logstash 7. There is a time problem in X. the difference between @ timestamp and local time is 8 hours

logstash 7. There is a time problem in X. the difference between @ timestamp and local time is 8 hours

2022-04-23 18:14:00 The hunter is eating meat

1、 problem :

edition :logstash-7.16.2

Logstash The time in is Greenwich mean time , yes 0 The time zone , And our time zone is East 8 District , So by logstash The data collected will be different from our time 8 Hour time difference .
When we are in the morning 8 At o'clock , Greenwich mean time is 0 spot , This will lead to problems related to time .

2、 resolvent

resolvent Is in Add... To the current time 8 Hours .

filter {
    
	
	ruby {
     
		code => "event.set('timestamp', event.get('@timestamp').time.localtime + 8*60*60)" 
	}	
	
	ruby {
    
		code => "event.set('@timestamp',event.get('timestamp'))"
	}
	
	mutate {
    
		remove_field => ["timestamp"]
	}
}

3、 test

restart logstash , You can see Timestamp and in the log content logstash The timestamp (@timestamp) Can be right .

 Insert picture description here

版权声明
本文为[The hunter is eating meat]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210611118598.html