Hi,
I am using logstash to convert below two strings into integer and then converting integer to milliseconds.
i have nginx logs with below values
request_time="0.051"
response_time="0.027"
first i am converting them into float
mutate {
convert => ["request_time", "float"]
convert => ["response_time", "float"]
}
and them am trying to convert them into milliseconds with below method, but am getting zero printing in the kibana
ruby {
code => "event.set('request_time', event.get('request_time').to_i * 1000)"
}
Badger
December 31, 2019, 3:14pm
2
The .to_i will round them down to zero, I think. Does it work if you use this?
(event.get('request_time') * 1000.0).to_i
Thats works, thanks for suggestion.
i have different issue while adding 2 strings into condition like below.
ruby {
code => "event.set('request_time', event.get('request_time') * 1000.0).to_i"
code => "event.set('response_time', event.get('response_time') * 1000.0).to_i"
}
is this correct format ?
Badger
December 31, 2019, 6:54pm
4
Not sure if that works or if one code option overwrites the other. I would use
ruby {
code => "
event.set('request_time', event.get('request_time') * 1000.0).to_i
event.set('response_time', event.get('response_time') * 1000.0).to_i
"
}
system
(system)
Closed
January 28, 2020, 7:14pm
6
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.