Skip to content

fdhhhdjd/class-prometheus-grafana-telegram-alerts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Š Telegram Alerts Monitoring Stack

class-prometheus-grafana-telegram-alerts

Node.js Prometheus Grafana Docker Telegram

A complete, containerized monitoring environment designed to simulate real-world application metrics, visualize them, and automatically send alerts to a Telegram chat.

Demo


πŸš€ Architecture Overview

Monitoring Architecture

Our stack is built on four core pillars:

  1. 🟒 Node.js App (Port 8081)
    A minimal Express backend using prom-client to expose metrics. Includes a dedicated /simulate-error endpoint to manually trigger issue scenarios for testing.
  2. πŸ”₯ Prometheus (Port 9090)
    A powerful time-series database configured to continuously scrape metrics exposed by the Node.js application and cAdvisor.
  3. 🐳 cAdvisor (Port 8082)
    Exposes real, system-level CPU and Memory metrics for the Docker containers, providing true resource consumption data.
  4. πŸ“ˆ Grafana (Port 4000)
    The visualization and alerting engine, completely pre-provisioned via code:
    • Data Source: Pre-linked to Prometheus.
    • Custom Dashboard: Live tracking of errors, error rates, real container CPU/RAM usage, and HTTP response times (p95 & p50).
    • Alerting: Pre-configured Notification Policies & Contact Points pointing directly to a custom Telegram channel.
    • Smart Rules: Instantly triggers notifications when the Node.js error counter spikes.

βš™οΈ Prerequisites

Before you begin, ensure you have the following installed:


πŸ› οΈ How to Run Locally

1. Clone the repository (or navigate to this environment folder):

git clone git@github.com:fdhhhdjd/class-prometheus-grafana-telegram-alerts.git
cd class-prometheus-grafana-telegram-alerts

2. Start the monitoring stack in detached mode:

docker compose up -d

Note: Wait a few moments for the containers to fully start and for Grafana to provision its plugins and modules.


πŸ” Accessing the Services

Once the stack is up and running, you can access the following interfaces:

Service Local URL Network IP Default Credentials
Node.js App http://localhost:8081 http://<ip>:8081 -
Prometheus http://localhost:9090 http://<ip>:9090 -
Grafana http://localhost:4000/dashboards http://<ip>:4000/dashboards admin / admin

🚨 How to Test Telegram Alerts

The stack comes fully prepared with your Telegram Bot credentials and Channel ID. Here's how to trigger an alert:

  1. Open Grafana: Go to the Node.js Application Dashboard in your browser.
  2. Trigger an Error: In a new tab, purposefully trigger a backend error by visiting the /simulate-error endpoint:
    http://localhost:8081/simulate-error
    
  3. Spike the Counter: Refresh the simulation page multiple times to simulate a surge in errors.
  4. Test Latency (Optional): Open another tab and hit the /slow endpoint to test HTTP response times:
    http://localhost:8081/slow
    
  5. Watch the Metrics: Return to the Grafana dashboard. Within 10 to 30 seconds, you will observe the graphs spiking.
  6. Check Telegram: Grafana will automatically evaluate the threshold rule, mark it as Firing, and dispatch an HTML-formatted alert securely via your bot to the Telegram chat! πŸ“²

About

🚨 This project is a complete, containerized monitoring environment designed to simulate real-world application metrics, visualize them, and automatically send alerts to a Telegram chat.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors