class-prometheus-grafana-telegram-alerts
A complete, containerized monitoring environment designed to simulate real-world application metrics, visualize them, and automatically send alerts to a Telegram chat.
Our stack is built on four core pillars:
- π’ Node.js App (Port
8081)
A minimal Express backend usingprom-clientto expose metrics. Includes a dedicated/simulate-errorendpoint to manually trigger issue scenarios for testing. - π₯ Prometheus (Port
9090)
A powerful time-series database configured to continuously scrape metrics exposed by the Node.js application and cAdvisor. - π³ cAdvisor (Port
8082)
Exposes real, system-level CPU and Memory metrics for the Docker containers, providing true resource consumption data. - π 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.
Before you begin, ensure you have the following installed:
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-alerts2. Start the monitoring stack in detached mode:
docker compose up -dNote: Wait a few moments for the containers to fully start and for Grafana to provision its plugins and modules.
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 |
The stack comes fully prepared with your Telegram Bot credentials and Channel ID. Here's how to trigger an alert:
- Open Grafana: Go to the Node.js Application Dashboard in your browser.
- Trigger an Error: In a new tab, purposefully trigger a backend error by visiting the
/simulate-errorendpoint:http://localhost:8081/simulate-error - Spike the Counter: Refresh the simulation page multiple times to simulate a surge in errors.
- Test Latency (Optional): Open another tab and hit the
/slowendpoint to test HTTP response times:http://localhost:8081/slow - Watch the Metrics: Return to the Grafana dashboard. Within 10 to 30 seconds, you will observe the graphs spiking.
- 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! π²

