This project demonstrates a simple Node.js Express server integrated with Prometheus for metrics collection and Grafana for visualization.
- Express Server: Simple API with standard and slow endpoints.
- Prometheus Integration: Uses
prom-clientto expose metrics at/metrics. - Dockerized Monitoring: Prometheus and Grafana are set up via Docker Compose.
Install dependencies and start the server:
npm install
npm run devThe server will be running at http://localhost:3002.
To start Prometheus and Grafana, use the following command:
docker-compose up -dIf you want to run Grafana separately using Docker:
docker run -d --name=grafana -p 3000:3000 grafana/grafana:latestGET /: Basic "Server is up and running" response.GET /slow: A mock slow endpoint (1-3s delay) with a 20% error rate for testing latency and error metrics.GET /metrics: Prometheus metrics endpoint.
- Prometheus: http://localhost:9090
- Grafana: http://localhost:3000
- Login:
admin/admin - Data Source: Add Prometheus with URL
http://prometheus:9090.
- Login:
index.js: Main server logic and metrics definitions.prometheus-config.yml: Prometheus scrape configuration (targets the Node.js server).docker-compose.yml: Docker services for Prometheus and Grafana.