~/CloudSetup.In

Prometheus

Monitoring prometheus.yml ● stable

Pull-based metrics collection, storage, and alerting.

01 Overview

Prometheus scrapes time-series metrics from targets on an interval, stores them locally, and evaluates alerting rules against them. Its query language, PromQL, is the standard most Grafana dashboards are built on top of.

→ official documentation

02 Installation

Pick a platform. Each step is copy-pasteable on its own.

01  Create a system user
sudo useradd --no-create-home --shell /bin/false prometheus
02  Download and extract the release
curl -LO https://github.com/prometheus/prometheus/releases/latest/download/prometheus-linux-amd64.tar.gz
tar xvf prometheus-linux-amd64.tar.gz
03  Install binaries and config
sudo mv prometheus-*/prometheus prometheus-*/promtool /usr/local/bin/
sudo mkdir -p /etc/prometheus /var/lib/prometheus
sudo mv prometheus-*/consoles prometheus-*/console_libraries /etc/prometheus/
04  Run it
prometheus --config.file=/etc/prometheus/prometheus.yml
01  Create a system user
sudo useradd --no-create-home --shell /bin/false prometheus
02  Download and extract the release
curl -LO https://github.com/prometheus/prometheus/releases/latest/download/prometheus-linux-amd64.tar.gz
tar xvf prometheus-linux-amd64.tar.gz
03  Install binaries and config
sudo mv prometheus-*/prometheus prometheus-*/promtool /usr/local/bin/
sudo mkdir -p /etc/prometheus /var/lib/prometheus
04  Run it
prometheus --config.file=/etc/prometheus/prometheus.yml
01  Install via Homebrew
brew install prometheus
02  Start the service
brew services start prometheus
Note — commands assume sudo privileges and an up-to-date package index. Pin a specific version in production rather than tracking latest.

03 Install script

The steps above bundled into a single idempotent shell script for provisioning boxes unattended.

install-prometheus.sh
Ubuntu/Debian target · safe to re-run · exits non-zero on failure
↓ download script

04 Cheatsheet

The commands reached for most often once Prometheus is installed.

CommandWhat it does
upPromQL: 1 for targets currently reachable
rate(http_requests_total[5m])Per-second request rate over 5 minutes
histogram_quantile(0.95, ...)Compute the 95th percentile from a histogram
promtool check config prometheus.ymlValidate a config file
curl localhost:9090/-/reloadHot-reload config (needs --web.enable-lifecycle)
curl localhost:9100/metricsRead raw metrics from node_exporter