How to install and configure Prometheus SNMP Exporter


1. Download & Install SNMP Exporter

  1. Grab the latest release from the official GitHub repo ([Grafana Labs][1])
  2. Unpack and install:
    “`bash
    wget https://github.com/prometheus/snmp_exporter/releases/download//snmp_exporter-.linux-amd64.tar.gz
    tar xzf snmp_exporter-*.tar.gz
    sudo mv snmp_exporter-.linux-amd64 /opt/snmp_exporter-
    sudo ln -s /opt/snmp_exporter- /opt/snmp_exporter
  1. Make the binary executable and optionally add /opt/snmp_exporter to your PATH (nsrc.org, sbcode.net)

2. Generate & Configure snmp.yml

  • Use the default snmp.yml (built around if_mib) for basic interface metrics.
  • For device-specific metrics, customize or generate a config using snmp_exporter’s generator tool to include CPU, memory, temperature, etc. (GitHub)
  • Place your MIB files (e.g. from vendors like Cisco) into a directory (e.g. /usr/share/snmp/mibs) and reference them if crafting custom modules (groups.google.com)

3. Install Supporting Tools (Linux)

Ensure SNMP tools and dependencies are installed:

  • On Ubuntu/Debian:
sudo apt update
sudo apt install gcc make net-snmp net-snmp-utils
  • On RHEL/CentOS:
sudo yum install gcc make net-snmp net-snmp-utils net-snmp-libs

This includes tools like snmpwalk, snmpget you can use to validate target devices before deploying the exporter (youtube.com, nsrc.org)


4. Run the Exporter

From the installation directory:

cd /opt/snmp_exporter
./snmp_exporter --config.file=snmp.yml

By default, it listens on port 9116 at /metrics, exposing its own internal metrics (prometheus.io)


5. Configure Prometheus to Scrape SNMP

Edit your prometheus.yml to add:

scrape_configs:
  - job_name: 'snmp'
    static_configs:
      - targets:
          - "192.0.2.5" # your device IP
    metrics_path: /snmp
    params:
      module: [if_mib] # matches one module in snmp.yml
    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 # exporter address

This enables Prometheus to send SNMP requests via the exporter to the target device (artifacthub.io, dbi-services.com)


6. Test SNMP Access

Before relying on the exporter, verify SNMP connectivity with standard tools:

snmpwalk -v2c -c public 192.0.2.5

or for SNMPv3:

snmpget -v3 -u <user> -l authPriv -a MD5 -A <authpass> -x DES -X <privpass> 192.0.2.5 .1.3.6.1.2.1.1.3.0

7. Validate & Verify

  • After starting Prometheus, visit http://<prometheus-host>:9090/targets to check the snmp job status.
  • If DOWN, confirm exporter is running and reachable.
  • Use curl http://localhost:9116/metrics to check exporter health.
  • Use curl 'http://localhost:9116/snmp?module=if_mib&target=192.0.2.5' to test probe metrics manually.

8. Advanced Tips & Best Practices

  • Before deploying custom MIB modules, test modules with the SNMP generator to ensure correct mapping of OIDs to metrics (docs-bigbang.dso.mil, GitHub)
  • Allocate unique ports when running multiple exporters on a host; the SNMP exporter defaults to 9116 (prometheus.io)
  • Protect any HTTP endpoint access (including /snmp or SNMP community/credentials) using network and monitoring security best practices (prometheus.io)
  • To avoid exposing sensitive SNMP strings in config, consider external secret files or tools that support secret hiding (discuss.prometheus.io)

✅ TL;DR

StepTask
1Download & unpack exporter binary
2Generate & customize snmp.yml with needed MIBs/modules
3Install SNMP tools (net-snmp, etc.)
4Launch exporter: ./snmp_exporter --config.file=snmp.yml
5Add snmp scrape config to prometheus.yml
6Validate via snmpwalk & Prometheus UI

Example Ubuntu Workflow

sudo apt update
sudo apt install wget net-snmp net-snmp-utils gcc make
wget https://github.com/prometheus/snmp_exporter/releases/download/0.20.0/snmp_exporter-0.20.0.linux-amd64.tar.gz
tar xzf snmp_exporter-*.tar.gz
sudo mv snmp_exporter-0.20.0.linux-amd64 /opt/snmp_exporter-0.20.0
sudo ln -s /opt/snmp_exporter-0.20.0 /opt/snmp_exporter
cd /opt/snmp_exporter
./snmp_exporter --config.file=snmp.yml &

Then configure Prometheus as shown above and restart it. After launch, check /targets and /metrics.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *