An example how to log and trace transactions in a microservice environment build with nestjs applications
An example can be found in enviroments/dev.env
Key | Value | Example |
---|---|---|
DEBUG | true or false - Specification of logs | true |
NODE_ENV | development or production | development |
HTTP_TIMEOUT | Time for HTTP timeouts | 10000 |
HTTP_MAX_REDIRECTS | HTTP redirects | 5 |
API_GLOBAL_PREFIX | Global api prefix (Important for Ingress | api |
API_PORT | Port on which the container is running | 8080 |
API_TITLE | Port on which the container is running | backend-for-frontend |
API_PREFIX | Port on which the container is running | BACKEND_FOR_FRONTEND_ |
API_DB_URL | Port on which the container is running | http://localhost:8081/api/ |
DATABASE_API_GLOBAL_PREFIX | Global api prefix (Important for Ingress | api |
DATABASE_API_PORT | Port on which the container is running | 8081 |
DATABASE_API_TITLE | Port on which the container is running | database-api |
DATABASE_API_PREFIX | Port on which the container is running | DATABASE_API_ |
$ npm i
Before the application is started for the first time, an .env
file must be created in the root folder
and filled with key-value pairs. An example can be found in environments/dev.env
.
$ nx serve api
$ nx serve api-database
$ nx serve frontend-app
To run the local Kubernetes cluster you need to have installed kind and Docker. Docker must also run.
kind create cluster --config=kind/kind.config.yaml
kind delete cluster --name nestjs-logging
To run the local Kubernetes cluster you need to have installed Terraform, kind and Docker. Docker must also run.
$ cd ./cluster
$ terraform init
$ cd ./cluster
$ terraform apply -auto-approve
$ cd ./cluster
$ terraform destroy --auto-approve
To deploy the charts you need to have installed Helm.
cd ./deployment
helm upgrade --install loki loki -f ./loki/values.yaml
helm uninstall loki
$ cd ./deployment
helm upgrade --install elk elk -f ./elk/values.yaml
helm uninstall elk
cd ./deployment
helm upgrade --install opensearch opensearch -f ./opensearch/values.yaml
helm uninstall opensearch
cd ./deployment
helm upgrade --install opensearch-sidecar opensearch-sidecar -f ./opensearch-sidecar/values.yaml
helm uninstall opensearch-sidecar
The project environment is created with Nx Workspace
Library: https://github.com/winstonjs/winston
Client: https://www.npmjs.com/package/@dollarsign/nestjs-jaeger-tracing