Deploy Prometheus on Ubuntu to scrape and store time-series metrics from your servers, containers, and applications — the foundation of the Grafana monitoring stack.
Grab the automated bash script from GitHub to follow along with the video.
wget https://raw.githubusercontent.com/mhmdali94/Docker/main/monitoring/prometheus/prometheus-ubuntu.sh
chmod +x prometheus-ubuntu.sh
sudo bash prometheus-ubuntu.sh
wget https://raw.githubusercontent.com/mhmdali94/Docker/main/monitoring/prometheus/prometheus-ubuntu.sh
chmod +x prometheus-ubuntu.sh
The script installs Docker if needed, then deploys Prometheus with a starter prometheus.yml scrape config.
sudo bash prometheus-ubuntu.sh
Open your browser and navigate to:
http://<your-server-ip>:9090
In Grafana, go to Connections → Data Sources → Add Prometheus with URL http://prometheus:9090 to start building dashboards.
| Port | Purpose |
|---|---|
| 9090 | Prometheus Web UI & API |
Prometheus is the de facto standard for metrics collection in modern infrastructure. It uses a pull model: Prometheus scrapes HTTP endpoints (/metrics) on a defined schedule, stores time-series data in its built-in TSDB, and exposes it via PromQL for querying. As a CNCF graduated project, it is the backbone of the Grafana + Prometheus + Loki observability stack used by thousands of companies.
Prometheus is the answer to 'how do I know what's happening inside my servers and applications?' Every major open-source project exposes a Prometheus-compatible /metrics endpoint. Once Prometheus is running, you get CPU, RAM, disk, network, and application-specific metrics for free — just add a scrape target.
Prometheus listens on port 9090. This is an internal port — expose it only within your Docker network for Grafana to query. Do not open it externally. Node Exporter listens on 9100 and cAdvisor on 8080 — both internal only.
VictoriaMetrics (Prometheus-compatible, lower memory, better compression), InfluxDB (push-based, SQL-like query), Netdata (auto-discovery, no config needed), Datadog (managed, expensive). Prometheus is the industry standard and is the right choice for the Grafana stack.
If you need push-based metrics ingestion (your apps can't expose a /metrics endpoint), InfluxDB or OpenObserve is a better fit. If you want zero-configuration monitoring that auto-discovers everything, Netdata is faster to start with. Prometheus shines when you want full control over what you scrape and how.
PrismaTechWork provides end-to-end infrastructure services — from initial deployment and security hardening to ongoing monitoring, automated backups, and dedicated support. Whether you need a single-server setup or a multi-site network, our team ensures your infrastructure is built right, secured properly, and maintained reliably.
Prometheus collects and stores metrics (the data layer). Grafana visualizes metrics (the presentation layer). They are complementary — Prometheus without Grafana gives you raw data; Grafana without Prometheus gives you a pretty UI with nothing to show. The standard practice is to run both together.
An exporter is a sidecar process that translates metrics from a system that doesn't natively speak Prometheus into the /metrics format. Node Exporter translates Linux kernel metrics. MySQL Exporter translates MySQL status variables. There are hundreds of community exporters for almost every software.
By default, 15 days. You can change this with the `--storage.tsdb.retention.time` flag. For longer-term storage, configure remote write to Thanos, Grafana Mimir, or VictoriaMetrics, which provide multi-year metric storage at low cost.
PromQL is Prometheus's query language for slicing, aggregating, and computing over time-series data. It has a learning curve, but most practical queries follow simple patterns: `rate(http_requests_total[5m])` gives you request rate; `avg by (instance)(cpu_usage)` gives per-host average. Grafana's dashboard explorer helps you learn by example.
Yes. Prometheus has a built-in Alertmanager integration. Define alert rules in a rules file, and Prometheus will fire them to Alertmanager, which routes notifications to Slack, PagerDuty, email, or webhook. Grafana adds a visual alerting layer on top, but is not required for basic alerting.
Run cAdvisor (Container Advisor) alongside your Docker daemon. It exposes a /metrics endpoint with per-container CPU, memory, network, and I/O metrics. Add it as a Prometheus scrape target in prometheus.yml and import the cAdvisor Grafana dashboard (ID 14282).
Prometheus uses a pull model (it scrapes targets), while InfluxDB uses a push model (applications write to it). Prometheus is designed for operational metrics with PromQL; InfluxDB is more general-purpose with SQL-like Flux queries. For the Grafana stack, Prometheus is the native choice.
Run `docker compose pull && docker compose up -d`. Prometheus TSDB data is stored in a named volume and is not affected by image updates. Check the Prometheus changelog for TSDB format changes before major version upgrades.