Skip to content
Back to Blog
Monitoring

Building a Network Monitoring Stack with Grafana + Prometheus

Deploy a complete observability stack using Prometheus for metric collection and Grafana for visualization of network KPIs.

May 2025
16 min read

Network Monitoring Stack: Prometheus + Grafana

This guide deploys a complete observability stack for network infrastructure using Docker Compose.

Docker Compose Stack

YAML
version: '3.8'
services:
  prometheus:
    image: prom/prometheus:latest
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
      - prometheus-data:/prometheus
    command:
      - '--config.file=/etc/prometheus/prometheus.yml'
      - '--storage.tsdb.retention.time=90d'
    ports:
      - "9090:9090"

  grafana:
    image: grafana/grafana:latest
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=SecurePass123
      - GF_INSTALL_PLUGINS=grafana-piechart-panel
    volumes:
      - grafana-data:/var/lib/grafana
    ports:
      - "3000:3000"

  snmp-exporter:
    image: prom/snmp-exporter:latest
    volumes:
      - ./snmp.yml:/etc/snmp_exporter/snmp.yml
    ports:
      - "9116:9116"

volumes:
  prometheus-data:
  grafana-data:

Prometheus Configuration

YAML
# prometheus.yml
global:
  scrape_interval: 60s

scrape_configs:
  - job_name: 'mikrotik'
    static_configs:
      - targets:
          - 192.168.1.1  # router1
          - 192.168.1.2  # router2
    metrics_path: /snmp
    params:
      module: [mikrotik]
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - target_label: __address__
        replacement: snmp-exporter:9116

  - job_name: 'linux-servers'
    static_configs:
      - targets:
          - server1:9100
          - server2:9100

Key Grafana Dashboards

Network Overview Dashboard panels:
  • Interface bandwidth (in/out) per device
  • Packet error rate per interface
  • BGP session states
  • OSPF neighbor count
  • CPU/RAM per network device

Useful PromQL Queries

PROMQL
# Bandwidth utilization %
rate(ifHCInOctets{ifAlias!=""}[5m]) * 8 / ifHighSpeed * 100

# Top 5 talkers
topk(5, rate(ifHCInOctets[5m]) * 8)

# Interface error rate
rate(ifInErrors[5m]) > 0

Alerting with Alertmanager

YAML
groups:
  - name: network
    rules:
      - alert: InterfaceDown
        expr: ifOperStatus == 2
        for: 2m
        labels:
          severity: critical
        annotations:
          summary: "Interface {{ $labels.ifAlias }} is down"