Install Graylog
In this step, you will install Graylog, a powerful open-source log management platform, in your LabEx VM environment. Graylog helps centralize and analyze log data for security monitoring and troubleshooting by collecting logs from various sources and providing search and visualization capabilities.
Since we're using Docker containers, we'll deploy Graylog using Docker Compose for easy setup. Docker Compose allows us to define and run multi-container applications with a single configuration file. This approach simplifies the installation process and ensures all required components work together properly. Follow these steps carefully:
- First, ensure you're in the correct directory. The
project
directory is where we'll organize our Graylog installation files:
cd ~/project
- Create a new dedicated directory for Graylog configuration. This keeps our installation files separate and organized:
mkdir graylog && cd graylog
- Create a
docker-compose.yml
file with the following content using nano. This file defines all the services Graylog needs to run:
nano docker-compose.yml
- Paste this configuration (press Ctrl+O to save, then Ctrl+X to exit). The configuration includes three main services:
- MongoDB for storing configuration data
- Elasticsearch for indexing and searching logs
- Graylog itself as the web interface and processing engine
version: "3"
services:
mongodb:
image: mongo:4.2
volumes:
- mongo_data:/data/db
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.2
volumes:
- es_data:/usr/share/elasticsearch/data
environment:
- "discovery.type=single-node"
- "bootstrap.memory_lock=true"
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
graylog:
image: graylog/graylog:4.3
volumes:
- graylog_data:/usr/share/graylog/data
environment:
- GRAYLOG_PASSWORD_SECRET=somepasswordpepper
- GRAYLOG_ROOT_PASSWORD_SHA2=8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
- GRAYLOG_HTTP_EXTERNAL_URI=http://127.0.0.1:9000/
depends_on:
- mongodb
- elasticsearch
ports:
- "9000:9000"
- "1514:1514"
- "1514:1514/udp"
- "12201:12201"
- "12201:12201/udp"
volumes:
mongo_data:
es_data:
graylog_data:
- Start the Graylog stack with Docker Compose. The
-d
flag runs containers in the background:
docker-compose up -d
- Verify the containers are running properly. This command shows the status of all services defined in our docker-compose file:
docker-compose ps
You should see three services (mongodb, elasticsearch, and graylog) with status "Up". The Graylog web interface will be available at http://127.0.0.1:9000
(username: admin
, password: admin
). This completes the basic Graylog installation, and we're now ready to configure log inputs in the next steps.