RousselTMLEARNING

Observability

Prometheus: visualizing your metrics (UI, Grafana and dashboards)

Visualize Prometheus data: the web interface, PromQL graphs, connecting to Grafana, RED and USE dashboards, variables, importing dashboards and Grafana alerts.

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 #

Prometheus and Grafana
Grafana stores no metrics: it queries the data source.
# 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 -> Prometheus

3. 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 Prometheus
Good practice: Use $__rate_interval rather 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, ...).

Related articles

Time-based vs event-based SLO: understanding, computing and choosing (with the Qonto example)

Differences between time-based SLOs (time slices, uptime) and event-based SLOs (good events over total): defi…

The observability trilemma: cost, completeness and performance, and how solutions resolve it

Understanding the observability trilemma (cost, data completeness, query performance), its three trade-offs, …

Prometheus recording rules: speeding up your queries and dashboards

Understand and master Prometheus recording rules: evaluation, naming convention, pitfalls (ratios, empty seri…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!