A quick centralised logging setup for Graylog (Version 1.2.1) and Logstash (Version 1.5.4). In this setup, Logstash will centralise and parse logs, and forward them to Graylog for analysis, visualisation and monitoring. The setup is created on docker for easy deployment and administration.
In this repoistory, a sample config file for is provided to parse live tweets. Please follow the instructions for the setup.
Note that this is still a work in progress.
- Ensure docker is installed
- Clone this repository
- Run the following commands:
cp logstash/sample-Dockerfile logstash/Dockerfile
cp logstash/sample-docker-compose.yml logstash/docker-compose.yml
cp graylog/sample-Dockerfile graylog/Dockerfile
cp graylog/sample-docker-compose.yml graylog/docker-compose.yml
- Navigate to the
graylog
folder, uncomment and edit the environment variables indocker-compose.yml
.
- Navigate to
logstash/
folder, and make the necessary changessample-twitter-demo.conf
. You will require app keys with Twitter.
The docker-compose files are deliberately kept separate for Graylog and Logstash. You may choose to create a single docker-compose file at the root.
- In the
graylog/
folder, run the following commands:
docker-compose build
docker-compose up
- Find the ip using
docker inpect gl
, and login to Graylog (http://x.x.x.x:9000) and add a GELF UDP input (System -> Inputs,Default Port: 12201
) - In the
graylog/
folder, run the following commands:
docker-compose build
docker-compose up
- Navigate back to Graylog to see live updates!
- Start both containers.
- Enter the logstash container:
docker exec -it ls bash
- Start another logstash instance to forward logs to Graylog :
/opt/logstash/bin/logstash -e 'input{stdin{}}output{gelf{host =>'gl'}}'
- Type something and verify whether the messages appear on Graylog.
- For additional patterns for log forwarding, modify the provided config files and logstash dockerfile.
- Remember to make the necessary changes in
Dockerfile
anddocker-compose.yml
(exposing of ports, adding of configuration files / patterns). - Note: The start script in the logstash container will run all config files that are added to
/etc/logstash/conf.d
.
- Please read the docs for scaling up Graylog in the future.
- You can experiment with more complex/advanced configurations of logstash when required.
The Logstash Dockerfile was adapted from Sébastien Pujadas, released under the Apache 2 license.
Sample