Hi Logstash,
I’m running the Logstash 7.7.0 Docker container, spun up on an Ubuntu machine. In my LS filter config, I “bounce” all of my records off an external C program via a TCP socket:
ruby {
init => "
require 'socket'
"
code => '
socket = TCPSocket.new("192.168.3.1", 12345)
socket.write event.to_hash
response = socket.recv(10000000)
event.set("NewData", response)
'
Fairly simple. The C program takes the entire data record, does some processing, and sends back a single string, which should never be more than 50 bytes long. The C program always sends back a string, even under default conditions.
But I’ve noticed that 33% of the time, I see a “null” value in the “NewData” field. That shouldn’t be. Also, I see a lot of this in the LS log:
[2020-10-09T16:34:10,476][ERROR][logstash.filters.ruby ][main][09de6b10cf3fdaa7a5ae8b4e3fcd73837267db580130edc34de5fc2c7e5e9cb2] Ruby exception occurred: Java heap space
I see this message hundreds of times. I don’t know what it means, but I’m guessing that something in the Ruby code calls Java, Java tries to allocate some memory, and the memory allocation fails. Java throws an exception, which causes Ruby to throw an exception, which causes the above error message. Maybe.
I’ve been rummaging about on the Elastic forum, and it looks like there have been similar-sounding issues to mine, such as this one. But the solution quoted here doesn’t seem to apply.
I’m also wondering if the Docker container might be imposing some limitations here? Perhaps a program within a container is only allowed to allocate so much system memory?
How does one troubleshoot something like this? Any suggestions? Much appreciated!