1. The native Prometheus interface #
An exploration tool.
What can the Prometheus UI do? #
The Prometheus web interface (port 9090) is designed for exploring: testing a PromQL query, checking target status (Status > Targets), looking at rules and alerts. It is not meant for building lasting dashboards: for that, you use Grafana.
# Vérifications rapides en ligne de commande
curl -s http://localhost:9090/-/healthy
curl -s 'http://localhost:9090/api/v1/targets' | jq '.data.activeTargets[] | {job: .labels.job, health: .health}'
curl -s 'http://localhost:9090/api/v1/query?query=up' | jq '.data.result[] | {instance: .metric.instance, up: .value[1]}'
curl -s 'http://localhost:9090/api/v1/query_range?query=rate(node_cpu_seconds_total[5m])&start=2026-10-18T08:00:00Z&end=2026-10-18T09:00:00Z&step=60'2. Connecting Grafana to Prometheus #
A complete stack in 2 minutes.
Docker Compose and provisioning #
# docker-compose.yml
services:
prometheus:
image: prom/prometheus:latest
ports: ["9090:9090"]
volumes: ["./prometheus.yml:/etc/prometheus/prometheus.yml"]
node-exporter:
image: prom/node-exporter:latest
ports: ["9100:9100"]
grafana:
image: grafana/grafana:latest
ports: ["3000:3000"]
volumes: ["./provisioning:/etc/grafana/provisioning"]# provisioning/datasources/prometheus.yml
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
url: http://prometheus:9090
isDefault: true
jsonData: { timeInterval: 15s }docker compose up -d
# Grafana : http://localhost:3000 (admin / admin) -> Explore -> Prometheus3. Building good dashboards #
The RED and USE methods.
The USE method for resources #
Utilization, Saturation, Errors: apply it to each resource (CPU, memory, disk, network).
# Utilisation CPU (%)
100 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[$__rate_interval])) * 100
# Saturation CPU (charge par cœur)
node_load1 / count by (instance) (node_cpu_seconds_total{mode="idle"})
# Mémoire utilisée (%)
(1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100
# Utilisation disque (%)
100 - (node_filesystem_avail_bytes{fstype!~"tmpfs|overlay"} / node_filesystem_size_bytes * 100)
# Débit réseau (octets/s)
sum by (instance) (rate(node_network_receive_bytes_total{device!="lo"}[$__rate_interval]))The RED method for services #
Rate (requests/s), Errors (error rate), Duration (latency): apply it to each service.
# Rate
sum by (service) (rate(http_requests_total[$__rate_interval]))
# Errors (%)
100 * sum by (service) (rate(http_requests_total{status=~"5.."}[$__rate_interval]))
/ sum by (service) (rate(http_requests_total[$__rate_interval]))
# Duration p95
histogram_quantile(0.95, sum by (le, service) (rate(http_request_duration_seconds_bucket[$__rate_interval])))Variables and importing dashboards #
# Variable "instance" (Dashboard settings > Variables > Query)
label_values(node_uname_info, nodename)
# Utilisation dans un panneau : node_load1{instance=~"$instance"}
# Importer le dashboard communautaire "Node Exporter Full" (ID 1860)
# Dashboards > New > Import > 1860 > choisir la source PrometheusGood practice: Use$__rate_intervalrather than a fixed window such as[5m]: Grafana adapts it to the graph's resolution and the scrape interval.
Common mistake: Avoid panels that aggregate hundreds of high-cardinality series: the browser and Prometheus get overwhelmed. Filter with variables and use topk(10, ...).