Logging is very important in microservices architecture as logs must be aggregated in
order to trace all the activities of a particular request from a consumer. We are using
ELK stack for logging. In production in Kubernetes cluster, there are vary options for
logging and we may replace Logstash with Fluentd. In this turorial, Elasticsearch,
Logstash and Kibana are all started in the same docker-compose.yml.
In order for the example-petstore container to forward log files to ELK, we need to
set up log driver on the application container to forward logs to Logstash and then
Bofore taking any action, let’s first kill the petstore docker container if it is still
For demo purposes, ELK will be started with a docker-compose locally. There is a compose
file available in light-docker called docker-compose-logging.yml
Please note that ElasticSearch has some requirements in memory, file handlers etc.
to start up. On my Linux desktop, I need to run the following.
sudo sysctl -w vm.max_map_count=262144
The following is the steps to start ELK locally.
docker-compose -f docker-compose-logging.yml up
You can goto http://localhost:9200 to confirm that ElasticSearch is running.
And you can goto http://localhost:5601 to confirm that Kibana is running.
With ELK running, here is the command line to start the petstore docker container.