This project demonstrates a simple microservices architecture using Node.js, Express, and Bun, fully instrumented with a Grafana monitoring stack (Prometheus, Promtail, and Loki).
First, install the dependencies required for the project:
bun install
# or
npm installYou can run the microservices directly on your host machine using Bun. Note that this requires you to have the monitoring stack running separately if you wish to visualize metrics, though the endpoints will still function.
Run a specific service:
bun run start:user # Starts User Service on port 3001
bun run start:product # Starts Product Service on port 3002
bun run start:order # Starts Order Service on port 3003Run all services at once (using concurrently):
bun run start:allTo run the entire ecosystem including all microservices and the monitoring stack, use the provided Docker Compose scripts.
This will build the Docker images and start everything in detached mode within a shared microservice-network network.
bun run docker:allTo tear down the containers and the network:
bun run docker:down:allIf you only want to spin up specific parts of the architecture:
bun run docker:user # Start User Service in Docker
bun run docker:product # Start Product Service in Docker
bun run docker:order # Start Order Service in Docker
bun run docker:monitoring # Start Grafana, Prometheus, Promtail, Loki in Docker(Each has a corresponding bun run docker:down:<name> command as well).
Once the services are running via Docker Compose (bun run docker:all), you can access the monitoring dashboard and endpoints:
- URL: http://localhost:3000
- Login Credentials:
- Username:
admin - Password:
admin
- Username:
- Data Sources: Prometheus and Loki are pre-provisioned. You can immediately go to the Explore tab to query metrics or logs.
- URL: http://localhost:9000
- Setup: Create your admin account upon first access to manage all running containers.
- URL: http://localhost:9090
- To verify that microservices are being correctly scraped, navigate to Status > Targets in the Prometheus UI.
Each service automatically exposes a /metrics endpoint that Prometheus scrapes. You can view the raw metric data here:
- User Service: http://localhost:3001/metrics
- Product Service: http://localhost:3002/metrics
- Order Service: http://localhost:3003/metrics
Promtail is configured to automatically capture stdout and stderr from all containers running on the Docker host.
- Open Grafana (http://localhost:3000).
- Navigate to Explore (compass icon on the left sidebar).
- Select Loki from the data source dropdown at the top.
- Run a LogQL query to view logs for a specific service. For example:
(Adjust the container name according to your Docker Compose setup, or use labels).
{container="user-service-user-service-1"}