[Source: Fabian Lee]
This is a simple guide to get the ELK stack up and running using Docker. Terraform Module is also provided.
- Docker
- Docker Compose
- Terraform (Optional)
Name | Description |
---|---|
docker-compose.yml |
Contains the configuration for the Docker Compose. |
docker-compose.yml |
Contains the configuration for the Docker Compose. |
docker/configs/logstash.conf |
Contains the configuration for Logstash. |
docker/logstash/ |
Contains all the default plugins, and MariaDB connector driver. |
app/__init__.py |
Contains the Flask application. |
app/models/ |
Contains the SQLAlchemy models. |
app/views/ |
Contains the Flask routes. |
- Clone this repository.
- Run
docker-compose -p elk-stack up -d --build
in thedocker/
directory of this repository or initialize Terraform and runterraform apply -auto-approve
in theterraform/
directory of this repository. - Wait for the containers to start up.
- Links to the services:
- Kibana: http://127.0.0.1:5601
- Elasticsearch: http://127.0.0.1:9200
- Logstash: http://127.0.0.1:5959
- Backend (Flask): http://127.0.0.1:5001
- MariaDB: http://127.0.0.1:3306
- PHPMyAdmin: http://127.0.0.1:8001
- Kibana
- Open Kibana in your browser.
- Click on
Management
in the left sidebar. - Click on
Index Patterns
. - Click on
Create Index Pattern
. - Enter
students
in theIndex pattern
field. - Click on
Next step
. - Click on
Create index pattern
. - Click on
Discover
in the left sidebar. - Click on
Add filter
. - Set
Field
tois_deleted
andOperator
tois not
and the value totrue
. - Click on
Apply filter
.
- Adding new Student
- Use any REST client to send a
POST
request to theBackend
service (URI: /students). - Use this JSON as the request body:
{ "name": "John Doe" }
- The response should be a
201
status code with the following JSON:
NOTE: Please note that the changes could take a few seconds to reflect in Kibana.{ "id": 1, "name": "John Doe", "is_deleted": false }
- Use any REST client to send a
- Updating a Student
- Use any REST client to send a
PUT
request to theBackend
service (URI: /students/{id}). - Use this JSON as the request body:
{ "name": "Jane Doe" }
- The response should be a
200
status code with the following JSON:
NOTE: Please note that the changes could take a few seconds to reflect in Kibana.{ "id": 1, "name": "Jane Doe", "is_deleted": false }
- Use any REST client to send a
- Deleting a Student
- Use any REST client to send a
DELETE
request to theBackend
service (URI: /students/{id}). - The response should be a
200
status code with the following textSet as Deleted
. The student is not actually deleted from the database, but is marked as deleted. - You can verify this by checking the
students
index in Kibana. NOTE: Please note that the changes could take a few seconds to reflect in Kibana.
- Use any REST client to send a