LOGSTASH convert unix ms timestamp

Are you sure that's wrong?

If I plug in “timeInMilliseconds” => 1504111665465, value into https://www.epochconverter.com, I see:

Assuming that this timestamp is in milliseconds:
GMT: Wednesday, August 30, 2017 4:47:45.465 PM

And your @timestamp value:

"@timestamp" => “2017-08-30T16:47:45.465Z”

Looks spot on to me.