I’m writing this blog to guide you through deploying and configuring the Prometheus SNMP Exporter on Kubernetes.
While there are several blogs already available on this topic, many don’t cover the real-world challenges that come up during deployment—especially when dealing with non-standard MIBs that can’t be directly converted using the SNMP generator tool.
In this post, we’ll walk through:
- Converting diverse MIB files (both standard and non-standard) into the required YAML format.
- Practical workarounds and techniques for successfully integrating problematic MIBs.
- Deploying the SNMP Exporter with secure SNMPv3 configurations
- How to troubleshoot when metrics don’t show up or connections fail
Think of this as your go-to guide for working with the SNMP Exporter on Kubernetes—especially when you’re dealing with edge cases and non-standard setups.
Prerequisites
- Kubernetes Cluster
- Helm v3+
- Network Connectivity – The Kubernetes cluster must have network access to the SNMP target devices.
- MIB Files – Obtain the required MIB files for the network devices you want to monitor
- SNMP Exporter Generator Tool
- Python (preferably v3.x) should be installed on your local machine or wherever you run the SNMP generator.
To ensure we cover these nuances thoroughly, this will be a comprehensive and detailed guide, so brace yourselves! In this post, I will cover:
Let’s start with converting vendor mib to yaml file.
Step1: Extracting OBJECT-TYPE from all given vendor mib’s
Download below script and extract it the location where all vendor mib’s are present.
Run the script: python getOID.py
The Script prints a list from each file, but just save only Final List at the end. It should start like “Unique OBJECT-TYPE names found”
Step2: SNMP Exporter Config Generator
This config generator uses NetSNMP to parse MIBs, and generates configs for the snmp_exporter using them.
# Debian-based distributions.
sudo apt-get install unzip build-essential libsnmp-dev # Debian-based distros
# Redhat-based distributions.
sudo yum install gcc make net-snmp net-snmp-utils net-snmp-libs net-snmp-devel # RHEL-based distros
git clone https://github.com/prometheus/snmp_exporter.git
cd snmp_exporter/generator
Before you continue, clear existing mib’s (if any)
rm -f /usr/share/snmp/mibs/*
rm -f $HOME/.snmp/mibs/*
Copy vendor mib’s to /usr/share/snmp/mibs and $HOME/.snmp/mibs directory and run below command:
dos2unix /usr/share/snmp/mibs/*.mib
dos2unix $HOME/.snmp/mibs/*.mib
Now go back to the generator folder earlier:
root@ubuntu-node:/home/ubuntu# cd snmp_exporter/generator
root@ubuntu-node:/home/ubuntu/snmp_exporter/generator# >generator.yml
Download below file, extract and edit:
Update, the generator.yml: add security details of snmp v3
In the modules section of generator.yml:
a. Choose the module name (Usually vendor name, in the example: MELLANOX). You need this module name during snmp exporter helm chart deployment, so remember it.
b. in the walk section under module, copy the list which you save earlier generated from getOID.py script.
Now, copy the updated generator.yml file to /home/ubuntu/snmp_exporter/generator folder and run, below command:
root@ubuntu-node# dos2unix /home/ubuntu/snmp_exporter/generator/generator.yml
If you get output like below, then congratulations you made it..!
root@ubuntu-node:/home/ubuntu/snmp_exporter/generator# ./generator generate
time=2023-10-06T10:09:03.107Z level=INFO source=net_snmp.go:174 msg="Loading MIBs" from=$HOME/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf
time=2023-10-06T10:09:03.115Z level=INFO source=main.go:57 msg="Generating config for module" module=MELLANOX
time=2023-10-06T10:09:03.117Z level=INFO source=main.go:75 msg="Generated metrics" module=MELLANOX metrics=522
time=2023-10-06T10:09:03.139Z level=INFO source=main.go:100 msg="Config written" file=/home/ubuntu/snmp_exporter/generator/snmp.yml
If you get below output, then no problem, will let you know how to take it forward
root@ubuntu-node:/home/ubuntu/snmp_exporter/generator# ./generator generate
time=2023-10-06T09:54:47.043Z level=INFO source=net_snmp.go:174 msg="Loading MIBs" from=$HOME/.snmp/mibs:/usr/share/snmp/mibs:/usr/share/snmp/mibs/iana:/usr/share/snmp/mibs/ietf
time=2023-10-06T09:54:47.046Z level=WARN source=main.go:179 msg="NetSNMP reported parse error(s)" errors=17
time=2023-10-06T09:54:47.046Z level=ERROR source=main.go:185 msg="Missing MIB" mib=SNMPv2-MIB from="At line 12 in /usr/share/snmp/mibs/IF-MIB.mib"
time=2023-10-06T09:54:47.046Z level=ERROR source=main.go:185 msg="Missing MIB" mib=IANAifType-MIB from="At line 13 in /usr/share/snmp/mibs/IF-MIB.mib"
time=2023-10-06T09:54:47.046Z level=ERROR source=main.go:185 msg="Missing MIB" mib=UUID-TC-MIB from="At line 16 in /usr/share/snmp/mibs/ENTITY-MIB.mib"
time=2023-105-06T09:54:47.046Z level=ERROR source=main.go:185 msg="Missing MIB" mib=IANA-ENTITY-MIB from="At line 18 in /usr/share/snmp/mibs/ENTITY-MIB.mib"
time=2023-10-06T09:54:47.049Z level=ERROR source=main.go:137 msg="Failing on reported parse error(s)" help="Use 'generator parse_errors' command to see errors, --no-fail-on-parse-errors to ignore"
List all missing MIB’s, in this case: SNMPv2-MIB, IANAifType-MIB, UUID-TC-MIB, IANA-ENTITY-MIB
Look for these mib’s in the below website and download them.
https://mibbrowser.online/mibdb_search.php
Repeat Step 1 and Step 2 again until you get config generated without any error.
Finally, copy the snmp.yml file for helm deployment.
Leave a comment