RousselTMLEARNING

Article · Prometheus: From Discovery to Expertise

Visualizing metrics with Grafana

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, ...).

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

My progress

  • ⏱ Estimated time : ≈ 9 min

Sign in to track your progress and take notes. Sign in

💬 Recent discussions about this course

Ask a question about this lesson →See all discussions about this course

Course Glossary

Alerting

The process of notifying teams (via email, Slack, Teams) when a specific event, threshold breach, or anomaly is detected.

Architecture

The overall structural design of an IT system, defining its various components, their relationships, and the principles guiding its evolution.

OpenTelemetry

An open source framework providing standards, APIs, and SDKs to collect and export observability data (traces, metrics, logs) in an agnostic way.

Recommended Articles

Grafana vs Kibana: which visualization tool to choose?

Discover the fundamental differences between Grafana, the king of multi-source metrics, and Kiban...

Prometheus best practices: metrics, cardinality, rules and operations

Prometheus best practices: metric naming, labels and cardinality, scrape intervals, recording rul...

PromQL: an introduction to the Prometheus query language

Learn PromQL, the Prometheus query language: selectors, rate, sum by, histograms and first querie...

Grafana Alloy: collecting system metrics and local logs

Learn how to configure Grafana Alloy to monitor the server it runs on, with a focus on configurat...

Prometheus recording rules: speeding up your queries and dashboards

Understand and master Prometheus recording rules: evaluation, naming convention, pitfalls (ratios...

Metric types in Prometheus

Discover in detail the four metric types supported by Prometheus (Counter, Gauge, Histogram, Summ...

Grafana Alloy: The importance of Self-Monitoring

Discover why and how to configure Grafana Alloy so that it monitors itself, collecting its own lo...

Traefik: metrics with Prometheus and OpenTelemetry

Expose Traefik metrics (Prometheus or OTLP), understand the series per entrypoint, router and ser...

Tempo: generating metrics from traces (service graph, span metrics, exemplars)

Enable Tempo's metrics-generator: service graphs, RED span metrics, remote write to Prometheus or...

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!