shazChaudhry / docker-elastic

Deploy Elastic stack in a Docker Swarm cluster. Ship application logs and metrics using beats & GELF plugin to Elasticsearch
347 stars 188 forks source link
docker-swarm-cluster elasticsearch filebeat gelf jenkins-container kibana log-aggregation logging logstash metricbeat travis

Build Status on Travis

User story

As a DevOps team member, I want to install Elastic Stack (v7.9.1 by default) so that all application and system logs are collected centrally for searching, visualizing, analyzing and reporting purpose

Elastic products

Assumptions

Architecture

The architecture used is shown in the table below

High level design In scope Not in scope
Elastic Stack Only beats for log files and metrics are used. All logs and metrics are shipped to elasticsearch directly in this repo.
2x Elasticsearch, 1x apm-server and 1x Kibana are used.
Ingest nodes are not used
Elastic Stack All containerized custom applications are designed to start with GELF log driver in order to send logs to Elastic Stack -

For the full list of free features that are included in the basic license, see: https://www.elastic.co/subscriptions

Prerequisite

Get docker compose files

You will need these files to deploy Eleasticsearch, Logstash, Kibana, and Beats. So, first SSH in to the master node of the Docker Swarm cluster allocated to running Elastic Stack and clone this repo by following these commands:

Deploy Elastic Stack

Deploy Beats

SSH in to the master node of the Docker Swarm cluster allocated to running containerized custom applications and beats. Clone this repo and change directory as per the instructions above.

Execute the following commands to deploy filebeat and metricbeat:

Filebeat

Metricbeat

Testing

Wait until all stacks above are started and are up and running and then run jenkins container where filebeat is running:

Sending messages to Logstash over gelf

Logstash pipeline is configured to accept messages with gelf log driver. Gelf is one of the plugin mentioned in Docker Reference Architecture: Docker Logging Design and Best Practices. Start an application which sends messages with gelf. An example could be as follows:

Here is another example:

Testing with APM Java Agent

Follow these instructions to build a java app that we will use for APM:

WIP

References