Project Demonstrating Observability For NodeJs Applications
This is a project demonstrating Observability using :
- Prometheus for monitoring and alerting
- Loki for Distributed Logging
- Tempo for Distributed Tracing
- Grafana for visualization
And basically integrates the following
- Opentelemetry
- Grafan Tempo Which internally uses Jaeger
- NodeJs Application
And basically it demonstrate the best practices for :
- Demonstrate how to use Opentelemetry API
- Logging : Using Log4js
- ES6 : Using Babel
- Metrics : Using Promclient
- Seperating configuration
- Containerization
Running
In Docker
docker-compose up --build
Access the endpoint
View the log and trace in Grafana
Get the trace information Using Jaeger
View the metrics in Prometheus
View prometheus metrics in Grafana
In Command prompt
Create .env file in root folder, refer this for more details on environment variables.
LOG_FILE_NAME=nodejs-opentelemetry-tempo.log
OTEL_SERVICE_NAME=nodejs-opentelemetry-tempo
OTEL_EXPORTER_JAEGER_ENDPOINT=http://localhost:14268/api/traces
DB_USER=sa
DB_PASS=P@ssw0rd
DB_SERVER=otmssql
DB_NAME=OtelTempo
Create Network
docker network create docker-tempo
Start tempo
ABSOLUTE_PATH_OF_PROJECT = E:\githubRepos\nodejs-opentelemetry-tempo
docker run -d --rm -p 6831:6831/udp -p 6832:6832/udp -p 9411:9411 -p 55680:55680 -p 3100:3100 -p 14250:14250 -p 14268:14268 --name tempo -v ${ABSOLUTE_PATH_OF_PROJECT}\etc\tempo-local.yaml:/etc/tempo.yaml --network docker-tempo grafana/tempo:latest --config.file=/etc/tempo.yaml
Start tempo query
docker run -d --rm -p 16686:16686 --name tempo-query -v ${ABSOLUTE_PATH_OF_PROJECT}\etc\tempo-query.yaml:/etc/tempo-query.yaml --network docker-tempo grafana/tempo-query:latest --grpc-storage-plugin.configuration-file=/etc/tempo-query.yaml
Start mssql
docker run -p 1433:1433 -d -e ACCEPT_EULA=Y --name otmssql -e SA_PASSWORD=P@ssw0rd --network docker-tempo mcr.microsoft.com/mssql/server
Connect to mssql and create db OtelTempo
and table as in .data\db\mssql\scripts
npm install
npm run dev
Access the endpoint
Get the trace information in Jaeger
Connecting To MSSQL DB
Lets connect to MSSQL DB running on container from Windows machine
Note : I have use heidisql, other option would be dbeaver