Monitoring and Logging with Node.js, Prometheus, and Grafana

Monitoring and Logging with Node.js, Prometheus, and Grafana

Overview

The repository includes a Node.js server built using Express.js, which handles HTTP requests. The server is integrated with Prometheus for collecting metrics and Grafana for visualizing these metrics. Additionally, Winston logger is used to log messages to a Loki instance.

Features

  1. Node.js Server: The server is built using Express.js and handles HTTP requests.

  2. Prometheus Integration: Prometheus is used to collect metrics from the server, including request-response times and total requests.

  3. Grafana Integration: Grafana is used to visualize the metrics collected by Prometheus.

  4. Logging: Winston logger is used to log messages to a Loki instance.

Getting Started

To set up the server, follow these steps:

  1. Clone the Repository: https://github.com/AkashBhadana/Nodeserver-Prometheus-Grafana.git

  2. Install Dependencies: npm install

  3. Start & Acess the Server: http://localhost:8000

  4. Access Prometheus: http://localhost:9090

5. Access Grafana: http://localhost:3000

Metrics

  1. Request-Response Time: The histogram http_express_req_res_time tracks the time taken by the server to respond to requests.

  2. Total Requests: The counter total_req counts the total number of requests made to the server.

Logging

  1. Winston Logger: Winston logger is used to log messages to a Loki instance.

  2. Loki Transport: The Loki transport is used to send logs to a Loki instance.