fbpx Prometheus + Grafana on Linux: Install and Create Dashboard (Guide) | Certificação Linux

Linux Monitoring with Prometheus and Grafana: From Zero to Dashboard

📅 07/19/2026 ⏱ 4 min ✍️ Uira Ribeiro
Linux Monitoring with Prometheus and Grafana: From Zero to Dashboard
Exam Pass App — mais de 7.000 questões LPI, offline, em 5 idiomas, disponível no Android e na App Store
Available on
Google Play
Available on
App Store

Prometheus + Grafana is the standard monitoring stack in the DevOps market. Prometheus collects and stores metrics in time series; Grafana transforms these metrics into visual dashboards and alerts. Together, they replace older tools like Nagios and Zabbix in modern environments.

Basic Architecture

Servidor Linux
└── Node Exporter (:9100)   ← expõe métricas do SO em /metrics

Servidor de Monitoramento
├── Prometheus (:9090)      ← faz scrape das métricas a cada 15s
│   └── AlertManager        ← dispara alertas (email, Slack, PagerDuty)
└── Grafana (:3000)         ← dashboard que lê do Prometheus

Installing Node Exporter (on servers to monitor)

# Baixar e instalar
VERSION="1.8.2"
wget https://github.com/prometheus/node_exporter/releases/download/v${VERSION}/node_exporter-${VERSION}.linux-amd64.tar.gz
tar xzf node_exporter-*.tar.gz
sudo mv node_exporter-*/node_exporter /usr/local/bin/
sudo chmod +x /usr/local/bin/node_exporter

# Criar service systemd
sudo tee /etc/systemd/system/node_exporter.service <<'EOF'
[Unit]
Description=Node Exporter
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/node_exporter
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now node_exporter

# Verificar métricas expostas
curl http://localhost:9100/metrics | head -30

Installing Prometheus

VERSION="2.53.0"
wget https://github.com/prometheus/prometheus/releases/download/v${VERSION}/prometheus-${VERSION}.linux-amd64.tar.gz
tar xzf prometheus-*.tar.gz
sudo mv prometheus-*/prometheus /usr/local/bin/
sudo mv prometheus-*/promtool   /usr/local/bin/

# Diretórios
sudo mkdir -p /etc/prometheus /var/lib/prometheus
sudo mv prometheus-*/prometheus.yml /etc/prometheus/

# Service systemd
sudo tee /etc/systemd/system/prometheus.service <<'EOF'
[Unit]
Description=Prometheus
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/prometheus   --config.file=/etc/prometheus/prometheus.yml   --storage.tsdb.path=/var/lib/prometheus   --storage.tsdb.retention.time=30d
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable --now prometheus

Configuring prometheus.yml

# /etc/prometheus/prometheus.yml
global:
  scrape_interval:     15s   # coleta métricas a cada 15 segundos
  evaluation_interval: 15s

scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]

  - job_name: "servidores_linux"
    static_configs:
      - targets:
          - "192.168.1.10:9100"   # web01
          - "192.168.1.11:9100"   # web02
          - "192.168.1.20:9100"   # db01
        labels:
          ambiente: "producao"
# Validar e recarregar configuração
promtool check config /etc/prometheus/prometheus.yml
sudo systemctl reload prometheus

Installing Grafana

# Ubuntu/Debian
sudo apt install -y apt-transport-https software-properties-common wget
wget -q -O - https://apt.grafana.com/gpg.key | sudo gpg --dearmor   -o /usr/share/keyrings/grafana.gpg
echo "deb [signed-by=/usr/share/keyrings/grafana.gpg] https://apt.grafana.com stable main"   | sudo tee /etc/apt/sources.list.d/grafana.list
sudo apt update && sudo apt install grafana -y

sudo systemctl enable --now grafana-server
# Acesse: http://SEU_IP:3000  |  admin / admin (troque na primeira vez)

Creating Your First Dashboard

  1. In Grafana: Connections → Add data source → Prometheus
    URL: http://localhost:9090 → Save & Test
  2. Dashboards → Import → ID 1860 (Node Exporter Full — public dashboard with +30 ready-made panels)
  3. Select the Prometheus data source and click Import

Dashboard 1860 already shows CPU, RAM, disk, network, system load and uptime of all your servers in real time, without writing any queries.

Basic PromQL Queries

# % de CPU em uso (total - idle)
100 - (avg by(instance)(rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)

# % de memória disponível
(node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100

# % de disco usado
100 - ((node_filesystem_avail_bytes{mountpoint="/"} /
        node_filesystem_size_bytes{mountpoint="/"}) * 100)

# Bytes recebidos por segundo na eth0
rate(node_network_receive_bytes_total{device="eth0"}[5m])

Alerts

# /etc/prometheus/rules/alertas.yml
groups:
  - name: infraestrutura
    rules:
      - alert: DiscoQuaseCheio
        expr: |
          100 - ((node_filesystem_avail_bytes{mountpoint="/"} /
                  node_filesystem_size_bytes{mountpoint="/"}) * 100) > 85
        for: 5m
        labels:
          severity: warning
        annotations:
          summary: "Disco acima de 85% em {{ $labels.instance }}"

      - alert: MemoriaInsuficiente
        expr: (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100 < 10
        for: 2m
        labels:
          severity: critical
        annotations:
          summary: "Menos de 10% de RAM disponível em {{ $labels.instance }}"

Why Prometheus + Grafana?

It is the standard observability stack in Kubernetes and cloud environments. Knowing how to configure metrics, dashboards and alerts is today a basic requirement for any SRE, DevOps or senior sysadmin position — and it greatly differentiates the resume of candidates applying for international remote positions.

Uira Ribeiro

Prof. Uirá Ribeiro

Chair do Board do Linux Professional Institute

After years of watching professionals waste hours on simple tasks because they didn't know the right Linux tools, I decided to teach.
Today I'm the author of most of LPI's official Learning Materials and mentor to over 14,000 certified students.

See my full story →

That was just one piece. The course teaches the whole path — from your first command to exam day.

Certificação Linux — a plataforma líder em certificações Linux no Brasil
WhatsApp