Skip to content
Dorian FINKEL
PrometheusSNMPMonitoringTutorial · 2026 · 4 min read · Updated 9 October 2026
Level · IntermediateDuration · 30 min

Monitor switches and routers with snmp_exporter

Network equipment can’t run an agent, but it speaks SNMP. snmp_exporter turns its counters into Prometheus metrics: throughput, errors and state of every port, over encrypted SNMPv3.

Prerequisites

  • Prometheus installed
  • snmp_exporter installed (binary or container)
  • Configuration access to the equipment

01The principle

Prometheus doesn’t query the device itself. It calls snmp_exporter (port 9116), passing the target, a module (what to read) and an auth (how to connect). The exporter queries the device over SNMP and returns the values in Prometheus format.

The if_mib module, shipped by default, covers the essentials: byte and error counters, state and speed of each interface.

02Enable SNMPv3 on the device

SNMPv1 and v2c send the community in clear text. SNMPv3 in authPriv mode authenticates and encrypts. An ACL limits queries to the monitoring server alone.

Example · Cisco IOS
ip access-list standard MONITORING
 permit host 192.168.5.20
!
snmp-server group PROM v3 priv access MONITORING
snmp-server user prometheus PROM v3 auth sha <password> priv aes 128 <key>

03Declare the auth

The shipped snmp.yml must not be edited by hand: it is generated. snmp_exporter accepts several configuration files and can read secrets from environment variables: the auth goes into a separate file.

Example · auths.yml
auths:
  prom_v3:
    version: 3
    username: prometheus
    security_level: authPriv
    auth_protocol: SHA
    password: ${SNMP_AUTH}
    priv_protocol: AES
    priv_password: ${SNMP_PRIV}

04Run and test

Example · Shell
snmp_exporter --config.file=snmp.yml --config.file=auths.yml \
              --config.expand-environment-variables

# Direct test, without Prometheus
curl 'http://localhost:9116/snmp?target=192.168.5.11&module=if_mib&auth=prom_v3'

05Declare it in Prometheus

The relabel_configs turn each target into the target parameter, keep the device’s address as the instance label, and send the request to the exporter.

Example · prometheus.yml
scrape_configs:
  - job_name: snmp
    static_configs:
      - targets: ['192.168.5.11', '192.168.5.12']
    metrics_path: /snmp
    params:
      auth: [prom_v3]
      module: [if_mib]
    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

06Useful queries

64-bit counters (ifHC…) avoid the too-fast wraparound of 32-bit counters on fast links.

Example · PromQL
# Inbound throughput in bit/s, per interface
rate(ifHCInOctets[5m]) * 8

# Interfaces administratively up but down
ifAdminStatus == 1 and ifOperStatus != 1

# Inbound errors per second
rate(ifInErrors[5m]) > 0

Key takeaways

  • Prometheus → snmp_exporter (9116) → device over SNMP.
  • SNMPv3 authPriv and an ACL: never a clear-text community.
  • snmp.yml is generated; the auth lives in a separate file.
  • 64-bit ifHC… counters and rate() for throughput.

Example addresses.

Official sources