A simple Express.js REST API application with built-in monitoring capabilities, containerized with Docker for easy local development.
- Features
- Prerequisites
- Installation
- Running the Application
- API Endpoints
- Available Scripts
- Project Structure
- Docker Configuration
- Monitoring
- Troubleshooting
- Contributing
- License
- Express.js REST API server
- Built-in health and metrics endpoints
- Docker containerization with development/production profiles
- Hot reload development with nodemon
- Lightweight and fast startup
- Ready for monitoring integration
- Node.js 18+
- Docker and Docker Compose
- npm or yarn
-
Clone the repository
git clone <repository-url> cd monitoring-get-started
-
Install dependencies
npm install
# Start the application locally
npm start
# Start with hot reload
npm run dev
The application will be available at http://localhost:3000
npm run docker:up-dev
npm run docker:up
GET /
- Root endpoint with API informationGET /api/test
- Test endpoint returning JSON responseGET /health
- Health check endpointGET /metrics
- Prometheus metrics endpoint
# Application Scripts
npm start # Start the application
npm run dev # Start with nodemon (hot reload)
# Docker Scripts
npm run docker:build # Build Docker images
npm run docker:up # Start production containers
npm run docker:up-dev # Start development container
npm run docker:down # Stop all containers
npm run docker:logs # View container logs
# Monitoring Scripts
npm run monitoring:up # Start monitoring stack
npm run monitoring:full # Start app + monitoring
npm run monitoring:down # Stop monitoring services
monitoring-get-started/
├── index.js # Main Express.js application
├── package.json # Dependencies and scripts
├── Dockerfile # Container configuration
├── docker-compose.yml # Multi-service orchestration
├── prometheus.yml # Prometheus configuration
├── grafana/ # Grafana provisioning
│ └── provisioning/
│ ├── datasources/ # Auto-configure Prometheus
│ └── dashboards/ # Pre-built dashboards
├── README.md # This file
└── MONITORING.md # Detailed monitoring guide
The application supports multiple deployment modes using Docker Compose profiles:
npm run docker:up-dev
- Hot reload with nodemon
- Source code mounted as volume
- Runs on port 3000
npm run docker:up
- Optimized production build
- No source code mounting
- Runs on port 3000
npm run monitoring:up
- Prometheus, Grafana, Node Exporter
- Data persistence with Docker volumes
- See MONITORING.md for details
This application includes built-in monitoring capabilities with Prometheus and Grafana.
For complete monitoring setup and usage instructions, see MONITORING.md
Quick monitoring commands:
npm run monitoring:full # Start app + full monitoring stack
npm run monitoring:up # Start monitoring services only
# Check if port 3000 is in use
lsof -i :3000
# View application logs
npm run docker:logs
# Rebuild containers
npm run docker:down
docker system prune -f
npm run docker:up
# Check container status
docker-compose ps
# Fix Docker volume permissions
sudo chown -R $USER:$USER .
If you encounter port conflicts, modify the ports in docker-compose.yml
:
- Application:
3000:3000
→YOUR_PORT:3000
- Monitoring services: See MONITORING.md
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the ISC License - see the package.json file for details.
Happy coding! 🚀