This repo serves as a functioning proof-of-concept for the video Logging Nodejs apps with ELK: Elasticsearch, Logstash, and Kibana.
You'll need docker desktop to run the example.
Type make up
to bring the docker-compose environment up. This will launch the ExpressJS application server, Elasticsearch,
Logstash, and Kibana.
Use make migrate
to create the database schema (required for the /users
endpoint) followed by make seed
to populate
the database with test data.
Once the environment is running, hit http://localhost:3000
and http://localhost:3000/users
to generate some logs.
The logs are sent to logstash using the winston-logstash-transport in ./helpers/logging.js
. Logstash is configured to send
the logs to Elasticsearch using the config found in elastic/logging.conf
.
Launch Kibana and follow the instructions to setup the logstash index pattern. You can then view the logs using Kibana Discovery.
The ExpressJS /
endpoint simply logs an info message. The /users
endpoint logs an info message but also some key/value
pairs that can be visualized in Kibana (and optionally reported/monitored/put on a dashboard/etc...)
Happy coding!