Question

I have a Logstash setup with Docker containers which looks like this:

Server A
    [Docker container]    Logstash
    [Docker container]    Elasticsearch
    [Docker container]    Kibana

Server B
    [Docker container]    My application
    [Docker container]    Logstash-forwarder

The Logstash-forwarder on server B sends all logs of My application to Logstash on server A. This works good, but every log message has the hostname of the Docker container (which is the ID of the container), e.g.:

host = 6c7f900f6b46

Since the Logstash-forwarder runs inside a Docker container, the hostname it will see (for itself) is the one inside the container. But this is not very useful for me. How can I use the hostname of the Docker-host?

Was it helpful?

Solution

There is no API available (as of Docker Remote API v1.11) to get the Docker hostname programmatically from within the container.

You can explicitly set the container's hostname when you run the container, docker run --hostname=, or you could set an environment variable with the Docker hostname at runtime and pass that value in your logs (docker --env=).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top