Skip to content

Containerized full-stack application (Express.js, React, MongoDB) with comprehensive monitoring via Prometheus and Grafana, deployed securely using Docker Compose. Features structured logging, metrics collection, and visualization through an integrated monitoring stack (Prometheus, Grafana, Loki, Promtail, cAdvisor, Node Exporter).

Notifications You must be signed in to change notification settings

TheArtifulProgrammer/nodejs-monitoring-grafana-prometheus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeJS Application Monitoring with Prometheus and Grafana

The application is containerized using Docker, with services orchestrated via Docker Compose. This ensures consistent deployment across different environments.

⚠️Security Note: This approach should be used only in development mode. For production, please use the implementation in the master-prod branch.

Components

Backend (Express.js)

  • RESTful API service built with Express.js
  • MongoDB integration for data persistence
  • Prometheus metrics instrumentation
  • Structured logging with Winston

Frontend (React)

  • User interface built with React
  • Axios for API communication
  • Served via Nginx

Database (MongoDB)

  • NoSQL database for storing application data
  • Initial data seeding through init script

Monitoring Stack

  • Prometheus: Metrics collection and storage
  • Grafana: Visualization and dashboarding
  • Loki: Log aggregation and storage
  • Promtail: Log collection agent
  • cAdvisor: Container metrics collection
  • Node Exporter: Host system metrics collection

Getting Started

Prerequisites

  • Docker and Docker Compose
  • Git
  1. Clone the repository
git clone https://github.com/TheArtifulProgrammer/nodejs-monitoring-grafana-prometheus
cd nodejs-monitoring-grafana-prometheus
  1. Install dependencies
npm install
  1. Run with Docker Compose
docker-compose up -d

Services

Monitoring Setup

The application includes:

  • Custom metrics endpoints
  • Default Node.js metrics
  • HTTP request metrics
  • System resource metrics

Configuration

Configuration files can be found in:

  • /config - Application configuration
  • /prometheus - Prometheus configuration
  • /grafana - Grafana dashboards

Contributing

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a new Pull Request

Future Improvements

  • Add more custom metrics
  • Implement alert rules
  • Add more detailed dashboards
  • Include logging integration
  • Add trace sampling

Author

Munashe Chinake https://theartfulprogrammer.com/

License

This project is licensed under the MIT License

Acknowledgments

  • Prometheus team
  • Grafana team
  • Node.js community

About

Containerized full-stack application (Express.js, React, MongoDB) with comprehensive monitoring via Prometheus and Grafana, deployed securely using Docker Compose. Features structured logging, metrics collection, and visualization through an integrated monitoring stack (Prometheus, Grafana, Loki, Promtail, cAdvisor, Node Exporter).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published