Logging to logstash from python

The real answer here is that python-logstash doesn't use the beats protocol. It uses TCP or UDP.

You can see this in your code logstash.TCPLogstashHandler(host, 5959, version=1)

You need to setup your ELK Docker image to have a TCP or UDP listener and then choose the matching handler in python-logstash to send messages.

Here is an example beats configuration file that you could include in the Docker image to listen on TCP port:

input {
    tcp {
    port => 5959
    codec => json
  }
}

If you named that file 03-tcp-input.conf then your Dockerfile might look like:

FROM sebp/elk

ENV LOGSTASH_PATH_CONF /etc/logstash

ADD ./03-tcp-input.conf ${LOGSTASH_PATH_CONF}/conf.d/03-tcp-input.conf

Study the Docker file in the source repo to understand how Sébastien setup the configuration for Logstash.


It does have something to do with beats, use this docker instead: github.com/deviantony/docker-elk and everything worked like a charm