This is a sample of how to send some information to logstash via the TCP input in nodejs or python. It assumes the logstash host is on 10.10.10.100 and the TCP listening input is 9563.
The logstash.conf should look something like the sample file.
The log message should be a stringified JSON object with the log message in the @message field.
To use, run the node script node sendMessageToLogstash.js
, or the python script python sendMessageToLogstash.js
I stumbled upon this while looking for a simple way to send logs directly to
Logstash
.I've used your basic idea and adjusted it to my needs:
Logstash
docker-elk/logstash/pipeline/logstash.conf
being the following:The script I used is this:
If you don't mind, I'm dropping it here in hopes it helps someone else when they scour the internet for similar problem. Thanks for the base code!