Last active
November 6, 2023 07:44
-
-
Save imweijh/cf7038b21c096a6fddd98229fce30679 to your computer and use it in GitHub Desktop.
logstash配置,在某个时间段,加tags,比如只在此时间段内才记录全量日志
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input { | |
generator { | |
lines => [ | |
"line 1", | |
"line a" | |
] | |
count => 1 | |
} | |
} | |
filter { | |
grok { match => [ "message", "^line \d$" ] } | |
ruby { | |
init => "require 'time'" | |
code => " | |
current_time = Time.now | |
start_time = Time.parse('09:20') | |
end_time = Time.parse('09:50') | |
if current_time >= start_time && current_time <= end_time | |
event.tag('logall') | |
else | |
event.tag('lognotall') | |
end | |
" | |
} | |
} | |
output { stdout { codec => rubydebug } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment