Last active
February 10, 2021 07:43
-
-
Save imweijh/f544c616b3cae2cd681bde18cd69b8ec to your computer and use it in GitHub Desktop.
logstash timestamp test
This file contains hidden or 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 { | |
message => "2020-02-10T15:14:15.003Z" | |
count => 1 | |
} | |
} | |
filter { | |
ruby { | |
code => " | |
event.set('s_time', Time.now) | |
# sleep(1) | |
# event.set('e_time', Time.now) | |
" | |
} | |
mutate { | |
add_field => { "timestamp_logstash_add_field" => "%{@timestamp}" } | |
} | |
ruby { | |
code => "event.set('timestamp_logstash_ruby',event.get('@timestamp'))" | |
} | |
grok { | |
match => { "message" => "%{TIMESTAMP_ISO8601:timestamp_source}" } | |
} | |
date { | |
match => [ "timestamp_source", "ISO8601" ] | |
} | |
ruby { | |
code => "event.set('time_elapsed_ruby',event.get('timestamp_logstash_ruby') - event.get('@timestamp'))" | |
} | |
} | |
output { stdout { codec => rubydebug } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment