Monitor OSPF network topology with Prometheus and Grafana dashboards

Advanced 45 min May 02, 2026 145 views
Ubuntu 24.04 Debian 12 AlmaLinux 9 Rocky Linux 9

Set up comprehensive OSPF network monitoring using FRRouting, Prometheus SNMP exporter, and Grafana dashboards to track network topology changes, LSA states, and routing convergence in real-time.

Prerequisites

  • Root or sudo access
  • Network interface with IP connectivity
  • Basic understanding of OSPF routing concepts
  • Minimum 2GB RAM for monitoring stack

What this solves

OSPF networks require constant visibility into topology changes, LSA propagation, and neighbor relationships to maintain optimal routing performance. This tutorial shows you how to implement comprehensive OSPF monitoring using FRRouting for OSPF routing, Prometheus SNMP exporter for metrics collection, and Grafana for visualization and alerting.

Step-by-step installation

Update system packages

Start by updating your package manager to ensure you get the latest versions of all components.

sudo apt update && sudo apt upgrade -y
sudo apt install -y curl wget gnupg2 software-properties-common
sudo dnf update -y
sudo dnf install -y curl wget gnupg2

Install FRRouting for OSPF

FRRouting provides enterprise-grade OSPF routing capabilities with extensive SNMP monitoring support.

curl -s https://deb.frrouting.org/frr/keys.asc | sudo apt-key add -
echo "deb https://deb.frrouting.org/frr $(lsb_release -s -c) frr-stable" | sudo tee -a /etc/apt/sources.list.d/frr.list
sudo apt update
sudo apt install -y frr frr-pythontools frr-snmp
sudo dnf install -y https://rpm.frrouting.org/repo/frr-stable-repo-1-0.el$(rpm -E %{rhel}).noarch.rpm
sudo dnf install -y frr frr-pythontools frr-snmp

Configure FRRouting OSPF

Enable OSPF and SNMP support in FRRouting configuration. This enables routing daemon monitoring via SNMP.

zebra=yes
ospfd=yes
ospf6d=no
ripd=no
ripngd=no
isisد=no
babeld=no
pimd=no
ldpd=no
nhrpd=no
eigr=no
sharpd=no
pbrd=no
staticد=no
bfd=no

SNMP support

snmp=yes

Configure OSPF routing

Set up OSPF areas and networks. This creates the routing topology that we'll monitor.

!
frr version 8.4.2
frr defaults traditional
hostname frr-router
log syslog informational
no ipv6 forwarding
service integrated-vtysh-config
!

OSPF Configuration

router ospf router-id 203.0.113.1 network 203.0.113.0/24 area 0.0.0.0 network 198.51.100.0/24 area 0.0.0.1 area 0.0.0.0 authentication message-digest area 0.0.0.1 stub passive-interface default no passive-interface eth0 no passive-interface eth1 redistribute connected redistribute static !

SNMP Configuration

snmp-server community public ro snmp-server community private rw snmp-server location "Network Operations Center" snmp-server contact "network-admin@example.com" ! line vty ! end

Start FRRouting services

Enable and start FRRouting to begin OSPF routing and SNMP data collection.

sudo systemctl enable frr
sudo systemctl start frr
sudo systemctl status frr

Install Prometheus

Prometheus will collect OSPF metrics via SNMP and store them for Grafana visualization.

wget https://github.com/prometheus/prometheus/releases/download/v2.45.0/prometheus-2.45.0.linux-amd64.tar.gz
tar -xzf prometheus-2.45.0.linux-amd64.tar.gz
sudo mv prometheus-2.45.0.linux-amd64 /opt/prometheus
sudo useradd -M -r -s /bin/false prometheus
sudo chown -R prometheus:prometheus /opt/prometheus

Install SNMP exporter

The SNMP exporter translates SNMP OIDs into Prometheus metrics, specifically for OSPF monitoring.

wget https://github.com/prometheus/snmp_exporter/releases/download/v0.24.1/snmp_exporter-0.24.1.linux-amd64.tar.gz
tar -xzf snmp_exporter-0.24.1.linux-amd64.tar.gz
sudo mv snmp_exporter-0.24.1.linux-amd64 /opt/snmp_exporter
sudo chown -R prometheus:prometheus /opt/snmp_exporter

Configure SNMP exporter for OSPF

Create SNMP exporter configuration with OSPF-specific OIDs for neighbor states, LSA counts, and topology changes.

auths:
  public_v2:
    community: public
    security_level: noAuthNoPriv
    auth_protocol: MD5
    priv_protocol: DES
    version: 2

modules:
  frrouting_ospf:
    walk:
      # OSPF General Group
      - 1.3.6.1.2.1.14.1.1    # ospfRouterId
      - 1.3.6.1.2.1.14.1.2    # ospfAdminStat
      - 1.3.6.1.2.1.14.1.3    # ospfVersionNumber
      - 1.3.6.1.2.1.14.1.4    # ospfAreaBdrRtrStatus
      - 1.3.6.1.2.1.14.1.5    # ospfASBdrRtrStatus
      
      # OSPF Area Table
      - 1.3.6.1.2.1.14.2.1.1  # ospfAreaId
      - 1.3.6.1.2.1.14.2.1.2  # ospfAuthType
      - 1.3.6.1.2.1.14.2.1.3  # ospfImportAsExtern
      - 1.3.6.1.2.1.14.2.1.4  # ospfSpfRuns
      - 1.3.6.1.2.1.14.2.1.5  # ospfAreaBdrRtrCount
      - 1.3.6.1.2.1.14.2.1.6  # ospfAsBdrRtrCount
      - 1.3.6.1.2.1.14.2.1.7  # ospfAreaLsaCount
      
      # OSPF Interface Table
      - 1.3.6.1.2.1.14.7.1.1  # ospfIfIpAddress
      - 1.3.6.1.2.1.14.7.1.3  # ospfIfAreaId
      - 1.3.6.1.2.1.14.7.1.5  # ospfIfState
      - 1.3.6.1.2.1.14.7.1.6  # ospfIfDesignatedRouter
      - 1.3.6.1.2.1.14.7.1.7  # ospfIfBackupDesignatedRouter
      - 1.3.6.1.2.1.14.7.1.8  # ospfIfEvents
      
      # OSPF Neighbor Table  
      - 1.3.6.1.2.1.14.10.1.1 # ospfNbrIpAddr
      - 1.3.6.1.2.1.14.10.1.3 # ospfNbrRtrId
      - 1.3.6.1.2.1.14.10.1.4 # ospfNbrOptions
      - 1.3.6.1.2.1.14.10.1.5 # ospfNbrPriority
      - 1.3.6.1.2.1.14.10.1.6 # ospfNbrState
      - 1.3.6.1.2.1.14.10.1.7 # ospfNbrEvents
      - 1.3.6.1.2.1.14.10.1.8 # ospfNbrLsRetransQLen
      
      # OSPF LSA Database
      - 1.3.6.1.2.1.14.4.1.1  # ospfLsdbAreaId
      - 1.3.6.1.2.1.14.4.1.2  # ospfLsdbType
      - 1.3.6.1.2.1.14.4.1.3  # ospfLsdbLsid
      - 1.3.6.1.2.1.14.4.1.4  # ospfLsdbRouterId
      - 1.3.6.1.2.1.14.4.1.5  # ospfLsdbSequence
      - 1.3.6.1.2.1.14.4.1.6  # ospfLsdbAge
      - 1.3.6.1.2.1.14.4.1.7  # ospfLsdbChecksum
    
    lookups:
      - source_indexes: [ospfNbrIpAddr]
        lookup: 1.3.6.1.2.1.14.10.1.6 # ospfNbrState
      - source_indexes: [ospfIfIpAddress] 
        lookup: 1.3.6.1.2.1.14.7.1.5  # ospfIfState
        
    overrides:
      ospfNbrState:
        type: gauge
      ospfIfState:
        type: gauge
      ospfAreaLsaCount:
        type: gauge
      ospfSpfRuns:
        type: counter

Create Prometheus configuration

Configure Prometheus to scrape OSPF metrics from the SNMP exporter targeting your FRRouting instances.

global:
  scrape_interval: 15s
  evaluation_interval: 15s

rule_files:
  - "/opt/prometheus/rules/*.yml"

alerting:
  alertmanagers:
    - static_configs:
        - targets:
          - alertmanager:9093

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

  - job_name: 'snmp-ospf'
    static_configs:
      - targets:
        - 203.0.113.1  # FRRouting router 1
        - 203.0.113.2  # FRRouting router 2 
        - 203.0.113.3  # FRRouting router 3
    metrics_path: /snmp
    params:
      module: [frrouting_ospf]
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9116  # SNMP exporter address
        
  - job_name: 'node-exporter'
    static_configs:
      - targets: 
        - 203.0.113.1:9100
        - 203.0.113.2:9100
        - 203.0.113.3:9100

Create OSPF alerting rules

Define Prometheus alerting rules for OSPF neighbor state changes and topology issues.

groups:
  • name: ospf.rules
rules: - alert: OSPFNeighborDown expr: ospfNbrState != 8 # 8 = Full state for: 30s labels: severity: critical service: ospf annotations: summary: "OSPF neighbor {{ $labels.ospfNbrIpAddr }} is not in Full state" description: "OSPF neighbor {{ $labels.ospfNbrIpAddr }} on router {{ $labels.instance }} is in state {{ $value }}, expected 8 (Full)" - alert: OSPFInterfaceDown expr: ospfIfState != 5 # 5 = DR/BDR state for broadcast networks for: 1m labels: severity: warning service: ospf annotations: summary: "OSPF interface {{ $labels.ospfIfIpAddress }} state changed" description: "OSPF interface {{ $labels.ospfIfIpAddress }} on router {{ $labels.instance }} is in state {{ $value }}" - alert: OSPFHighLSACount expr: ospfAreaLsaCount > 1000 for: 5m labels: severity: warning service: ospf annotations: summary: "High LSA count in OSPF area {{ $labels.ospfAreaId }}" description: "OSPF area {{ $labels.ospfAreaId }} has {{ $value }} LSAs, investigate network stability" - alert: OSPFHighSPFRuns expr: increase(ospfSpfRuns[5m]) > 10 for: 1m labels: severity: warning service: ospf annotations: summary: "High SPF calculation frequency in area {{ $labels.ospfAreaId }}" description: "OSPF area {{ $labels.ospfAreaId }} had {{ $value }} SPF runs in 5 minutes, indicating network instability"

Create systemd services

Create systemd service files for Prometheus and SNMP exporter to ensure they start automatically.

[Unit]
Description=Prometheus
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/opt/prometheus/prometheus \
    --config.file=/opt/prometheus/prometheus.yml \
    --storage.tsdb.path=/opt/prometheus/data \
    --web.console.templates=/opt/prometheus/consoles \
    --web.console.libraries=/opt/prometheus/console_libraries \
    --web.listen-address=0.0.0.0:9090 \
    --web.enable-lifecycle
    
[Install]
WantedBy=multi-user.target

Create SNMP exporter service

Configure the SNMP exporter as a systemd service for automatic startup and monitoring.

[Unit]
Description=SNMP Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=prometheus
Group=prometheus
Type=simple
ExecStart=/opt/snmp_exporter/snmp_exporter --config.file=/opt/snmp_exporter/snmp.yml
Restart=always

[Install]
WantedBy=multi-user.target

Start monitoring services

Enable and start both Prometheus and SNMP exporter services.

sudo systemctl daemon-reload
sudo systemctl enable prometheus snmp-exporter
sudo systemctl start prometheus snmp-exporter
sudo systemctl status prometheus snmp-exporter

Install Grafana

Install Grafana for visualizing OSPF network topology and metrics collected by Prometheus.

wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
sudo apt update
sudo apt install -y grafana
sudo dnf install -y https://dl.grafana.com/oss/release/grafana-10.2.0-1.x86_64.rpm

Configure Grafana data source

Add Prometheus as a data source in Grafana to access OSPF metrics.

sudo systemctl enable grafana-server
sudo systemctl start grafana-server

Wait for Grafana to start, then configure data source

sleep 10 curl -X POST \ http://admin:admin@localhost:3000/api/datasources \ -H 'Content-Type: application/json' \ -d '{ "name": "Prometheus", "type": "prometheus", "url": "http://localhost:9090", "access": "proxy", "isDefault": true }'

Import OSPF dashboard

Create a comprehensive OSPF monitoring dashboard in Grafana with network topology visualization.

{
  "dashboard": {
    "id": null,
    "title": "OSPF Network Monitoring",
    "tags": ["ospf", "networking", "frrouting"],
    "timezone": "browser",
    "panels": [
      {
        "id": 1,
        "title": "OSPF Neighbor States",
        "type": "stat",
        "targets": [{
          "expr": "count by (instance) (ospfNbrState == 8)",
          "refId": "A",
          "legendFormat": "{{instance}} - Full Neighbors"
        }],
        "gridPos": {"h": 8, "w": 12, "x": 0, "y": 0}
      },
      {
        "id": 2,
        "title": "LSA Database Size",
        "type": "graph",
        "targets": [{
          "expr": "ospfAreaLsaCount",
          "refId": "A",
          "legendFormat": "Area {{ospfAreaId}} - LSA Count"
        }],
        "gridPos": {"h": 8, "w": 12, "x": 12, "y": 0}
      },
      {
        "id": 3,
        "title": "SPF Calculation Frequency",
        "type": "graph",
        "targets": [{
          "expr": "rate(ospfSpfRuns[5m]) * 300",
          "refId": "A",
          "legendFormat": "{{instance}} - Area {{ospfAreaId}}"
        }],
        "gridPos": {"h": 8, "w": 24, "x": 0, "y": 8}
      },
      {
        "id": 4,
        "title": "OSPF Interface States",
        "type": "table",
        "targets": [{
          "expr": "ospfIfState",
          "refId": "A",
          "format": "table",
          "instant": true
        }],
        "gridPos": {"h": 8, "w": 24, "x": 0, "y": 16}
      }
    ],
    "time": {"from": "now-1h", "to": "now"},
    "refresh": "30s"
  }
}

Import the dashboard

Load the OSPF dashboard configuration into Grafana via the API.

curl -X POST \
  http://admin:admin@localhost:3000/api/dashboards/db \
  -H 'Content-Type: application/json' \
  -d @/tmp/ospf-dashboard.json
Security Note: Change the default Grafana admin password immediately after installation. Use sudo grafana-cli admin reset-admin-password newpassword or configure authentication through the web interface.

Configure advanced OSPF monitoring

Enable detailed OSPF logging

Configure FRRouting to log detailed OSPF events for troubleshooting and analysis.

sudo vtysh -c 'configure terminal' \
  -c 'log file /var/log/frr/ospfd.log' \
  -c 'debug ospf event' \
  -c 'debug ospf lsa' \
  -c 'debug ospf neighbor' \
  -c 'write memory'

Configure log rotation

Set up log rotation for OSPF logs to prevent disk space issues.

/var/log/frr/*.log {
    daily
    missingok
    rotate 14
    compress
    delaycompress
    notifempty
    create 640 frr frr
    postrotate
        /bin/kill -USR1 cat /var/run/frr/*.pid 2> /dev/null 2> /dev/null || true
    endscript
}

Set up network topology discovery

As mentioned in automated network topology discovery, you can enhance monitoring by adding LLDP data collection for complete network mapping.

# Install LLDP daemon
sudo apt install -y lldpd

Enable SNMP in LLDP configuration

echo 'configure system interface pattern *' | sudo lldpcli echo 'configure system description "OSPF Router"' | sudo lldpcli

Start LLDP service

sudo systemctl enable lldpd sudo systemctl start lldpd

Verify your setup

Confirm that all monitoring components are working correctly and collecting OSPF metrics.

# Check FRRouting OSPF status
sudo vtysh -c 'show ip ospf neighbor'
sudo vtysh -c 'show ip ospf database'

Verify SNMP is responding

snmpwalk -v2c -c public localhost 1.3.6.1.2.1.14.10.1.6 # OSPF neighbor states

Test SNMP exporter

curl http://localhost:9116/snmp?target=127.0.0.1&module=frrouting_ospf

Check Prometheus targets

curl http://localhost:9090/api/v1/targets

Verify Grafana is accessible

curl http://localhost:3000/api/health

Test OSPF metrics in Prometheus

curl 'http://localhost:9090/api/v1/query?query=ospfNbrState'

Common issues

SymptomCauseFix
SNMP exporter returns no metricsSNMP community mismatch or firewall blockingVerify /etc/frr/frr.conf SNMP community matches exporter config
OSPF neighbors not appearingNetwork connectivity or authentication issuesCheck sudo vtysh -c 'show ip ospf neighbor' and interface states
Grafana dashboard shows no dataPrometheus not scraping SNMP exporterCheck Prometheus targets at http://localhost:9090/targets
High memory usage on routerToo frequent SNMP pollingIncrease scrape_interval in prometheus.yml to 30s or 60s
Missing LSA database metricsOSPF not fully convergedWait for OSPF convergence or check area configuration
Permission denied on log filesIncorrect file ownershipsudo chown frr:frr /var/log/frr/*.log

Next steps

Running this in production?

Want this handled for you? Running OSPF at scale adds a second layer of work: capacity planning, failover drills, cost control, and on-call expertise. See how we run infrastructure like this for European teams.

Automated install script

Run this to automate the entire setup

Need help?

Don't want to manage this yourself?

We handle private cloud infrastructure for businesses that depend on uptime. From initial setup to ongoing operations.