Prometheus SNMP Exporter: Network Monitoring Tutorial!

preview_player
Показать описание
Master network monitoring with this comprehensive tutorial on Prometheus SNMP Exporter and Grafana. Learn how to efficiently collect network device metrics using Prometheus SNMP Exporter and visualize them into actionable insights with stunning Grafana dashboards. Discover how to create custom dashboards, troubleshoot common issues, and unlock the full potential of Prometheus and Grafana for your network monitoring needs.

Snmpwalk confirmation
snmpwalk -v3 -l authPriv -u admin -a SHA -A "PWt89voowUiDcJBi9boiSM" -x AES -X "PWt89voowUiDcJBi9boiSM" 192.168.0.84

#### snmp exporter docker compose file ####
---
services:
snmp-exporter:
container_name: snmp-exporter
ports:
- "9116:9116"
- "161:161/udp"
volumes:
- ./config:/etc/snmp-exporter
restart: unless-stopped
networks:
prometheus_frontend:
ipv4_address: 172.19.0.12

networks:
prometheus_frontend:
external: true

#### Git clone snmp_exporter project ####

#### Install dependencies and compile generator ####
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 golang

#### Compile generator ####
make generator mibs

#### Generator config modification ####
walk:
- sysUpTime
- interfaces
- ifXTable
- sysName
- ifHCInOctets
- ifHCOutOctets
- ifInErrors
- ifOutErrors

#### Prometheus docker configuration ####
---
services:
prometheus:
image: prom/prometheus:v2.53.0
container_name: prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus:/etc/prometheus
- ./prometheus-data:/prometheus
restart: unless-stopped
networks:
frontend:
ipv4_address: 172.19.0.11

networks:
frontend:
driver: bridge
ipam:
config:
- subnet: 172.19.0.0/16
gateway: 172.19.0.1

#### Prometheus conf file ####
---
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'snmp'
static_configs:
- targets:
- 192.168.0.84 # SNMP device.
metrics_path: /snmp
params:
auth: [public_v3]
module: [if_mib]
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 192.168.0.153:9116 # The SNMP exporter's real hostname:port.

#### Grafana docker configuration ####
---
services:
grafana:
image: grafana/grafana-oss:10.2.8
container_name: grafana
ports:
- "3000:3000"
volumes:
- ./grafana-data:/var/lib/grafana
restart: unless-stopped
networks:
prometheus_frontend:
ipv4_address: 172.19.0.13

networks:
prometheus_frontend:
external: true

#### Grafana Dashboard ####
Total Traffic
sum(irate(ifHCInOctets{instance="$Device"}[$__rate_interval]) * 8)
sum(irate(ifHCOutOctets{instance="$Device"}[$__rate_interval]) * 8)

IN & OUT per interface
irate(ifHCInOctets{instance="192.168.0.84",ifIndex="2"}[$__rate_interval]) * 8
irate(ifHCOutOctets{instance="192.168.0.84",ifIndex="2"}[$__rate_interval]) * 8

Uptime
sysUpTime{instance="$Device"} * 10

System name
sysName{instance="$Device"}

0:00 - What you need
0:23 - Unifi SNMP v3
1:08 - Linux snmp tools
2:43 - snmp exporter docker compose
4:11 - snmp generator
5:49 - generator config
7:11 - snmp compiled config
8:25 - prometheus docker compose
10:34 - snmp exporter container confirmation
11:17 - grafana docker compose
12:26 - prometheus data source
13:13 - grafana snmp dashboards
13:41 - fixing prometheus
14:21 - switch hostname panel
15:15 - switch total traffic panel
17:48 - switch port traffic panel
19:32 - switch uptime panel

#prometheus #snmp #snmp_exporter #networkmonitoring #devops
Рекомендации по теме
Комментарии
Автор

Ok nevermind, it works. Thanks for this Video i watched it maybe 100 times this week but now it works. :D

Sonnenblume
Автор

Great video. Cheers.
This worked for me with Unifi network version: 9.0.108
snmpwalk -c public -v 3 -l authPriv -u <Username> -a SHA -A <Password> -x AES-128 -X <Password> <Unif Gateway IP>

KalsangDorjee
Автор

Thank you very much for sharing your knowledge, it is helping me a lot. The tutorial was really good! I'm looking from here in Brazil.

MmauricioHirsch
Автор

Great tutorial!
one little thing the total traffic sums all traffic on all interfaces gives you the "same" traffic for in and out (due to router perspective of wan vs internal interfaces )I think its better to look at the wan interface for in out and sum all internal interfaces

BoazLowenstein
Автор

Very helpful video thanks. I successfully did a make generator mibs, but I have manually downloaded my mibs and whacked in the mibs directory and tried to proceed with the tutorial (no joy)

I don't suppose you're able to advise? (I assumed I might have to modify the makefile, but am not very experienced (needed quite a bit of help to get to this point)

Any guidance would be great, am after the Peplink 8.4.0 mibs (on their misc downloads)

thomastailford
Автор

This is an excellent video, well thought out, well presented, perfectly explained. This will help a lot of people!
How about if you have 250 devices?
This solution seems like it would take a long time. Perhaps if I were a cat with 7 lives then I could use 3 of them to configure Prometheus and get it to work in a medium sized business with about 65 devices across several locations.

douglaspayne
Автор

Thanks for the guide, seems like "- target_label: __ address__ " in the description has been screwed up by the formatting and changed to "- target_label: _ address_ " (_ changes the text formatting to italic). Sorry for the extra spaces, couldn't figure out how to do the proper formatting my self...
One suggestion would be to create a GitHub gist instead with the code

RealRokton
Автор

Hey man you did great things keep it up and please do firewall monitoring use SNMP prometheus grafana

Mr.Abd
Автор

very useful tuto ... everything ok exept for synology .. I have some fields with no datas :( .. nice tuto thx

anthonycoppet
Автор

This was an amazing tutorial to get things running, quick question though, i wanted to update the modules with the vendor specfic mibs and thought i did it right, but it broke everything. I followed the basic instructions on how to update mibs

defxed
Автор

Thank you so much! really great video, keep it up!!

jostpozman
Автор

Great video. Can you post the commands to build SNMP generator from an Ubuntu host?

cocoloconuevo
Автор

This is a wonderful video. How can we add the CPU and Memory to this of the switch?

Gnzuk
Автор

Can someone help me correct what's wrong in docker-compose file? I'm getting " yaml: line 8: could not find expected ':' " I didn't change anything except for the IP addresses.

andyamarsanaa
Автор

Great guide, how to enable Prometheus to walk the entire device so I can also get metrics for CPU, memory, icmpOutErrors and temperature

mancobasanele
Автор

Hi sir, can u test on fortigate? i need a direction properly for monitoring fortigate. thx Sir

nfs-gm
Автор

I'm running into this error when I'm trying to run *make generator mibs*

make: go: No such file or directory
make: *** [Makefile:87: generator] Error 127

I've searched high and low on YouTube and Google... nothing... everyone who is doing this tutorial has no problems... Do you have any suggestions? Thanks!

TheBroadcastEngineer
Автор

Thank you for this. Would this process work with Cisco devices.

damolaazeez
Автор

Hi that is only possible with snmp v3? its not allow to v1 or v2?

stefhaniemilagrosjaramillo
Автор

I am running into this error now

<IP>:port/config is showing {} (blank) config page
public_v3 is throwing this error message, "Unknown auth 'public_v3'".

I wonder if not using TLS connection is causing this behavior? Any suggestions/solution ?

johnconnor
welcome to shbcf.ru