Monitor your service with Grafana & Prometheus
Deploy Prometheus, node_exporter and Grafana to collect, store and visualize your instance's metrics.
Monitor your service with Grafana & Prometheus
Prometheus collects and stores metrics (CPU, RAM, traffic), Grafana renders them in dashboards. The pair is the self-hosted observability standard.
Cause / The problem
Without monitoring, you discover outages when they hit: a full disk, saturated RAM, climbing latency. You must capture metrics continuously and visualize them to get ahead.
Solution
- Run Prometheus with this
prometheus.yml:global: scrape_interval: 15s scrape_configs: - job_name: "node" static_configs: - targets: ["localhost:9100"] - Start the stack with Docker:
docker run -d -p 9090:9090 -v ./prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus - Add node_exporter for system metrics (CPU, RAM, disk):
docker run -d -p 9100:9100 --net=host prom/node-exporter - Start Grafana:
Default login:docker run -d -p 3000:3000 grafana/grafanaadmin/admin(change it immediately). - Add Prometheus as a data source in Grafana: Connections → Data sources → Add → type Prometheus, URL
http://localhost:9090, then Save & test. - Import a dashboard: Dashboards → New → Import → enter ID 1860 (Node Exporter Full) and pick your Prometheus source.
- Set up an alert: in Alerting, create a rule (e.g.
node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes < 0.1for a RAM < 10% alert), then wire it to a contact point (email, webhook).
Put Grafana and Prometheus behind an HTTPS reverse proxy (see the dedicated article), and never expose them without authentication.