Exporting Juniper SRX metrics via SNMP with Prometheus
Description
Setup SNMP Prometheus exporter to scrape metrics from Juniper Hardware, specifically tested for the SRX switches. Having looked online i dont see any examples of anyone doing this and so have created a dashboard and process to get this setup.
My homelab setup is an SRX220H2 running Junos 12.3.
Setup SNMP exporter
First thing you need to do is create a snmp.yml file, you do not create this directly instead you create a generator.yml which uses the MIBs to create a working snmp.yml.
Create your /etc/prometheus/generator.yml
generator.yml
modules:
srx220h2:
version: 2
auth:
community: "homelab" # or your SNMPv2c community
walk:
- sysUpTime
- jnxRedAlarmState
- jnxYellowAlarmState
- ifTable
- ifXTable
- jnxOperatingTable # chassis temps, CPU, memory
- jnxJsSPUMonitoringObjectsTable # SRX session & SPU stats
lookups:
- source_indexes: [ifIndex]
lookup: ifDescr
- source_indexes: [ifIndex]
lookup: ifAlias
Get the MIBS for junos 12.3 extract and copy to /usr/share/snmp/mibs/
wget https://www.juniper.net/documentation/software/junos/junos123X48/juniper-mibs-12.3X48-D10.3.zip
unzip juniper-mibs-12.3X48-D10.3.zip
cp * /usr/share/snmp/mibs/
Configure snmp and generate the snmp.yml
/etc/snmp/snmp.conf
mibs +ALL
mibdirs /usr/share/snmp/mibs
cd /etc/prometheus
/usr/bin/prometheus-snmp-generator generate
You should now have a working snmp.yml
start the exporter and ensure listening on tcp 9116
systemctl start prometheus-snmp-exporter
If this failed check versions and compatibility.
Setup Prometheus
In prometheus.yml configure a new job for Junos hardware
- job_name: 'junos_switches'
scrape_interval: 60s
scrape_timeout: 30s # slightly longer than SNMP exporter timeout
metrics_path: /snmp
params:
module:
- srx220h2
file_sd_configs:
- files:
- 'file_sd/junos_targets.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
With a job configured for junos switches add an instance (list of target IPs) to monitor:
file_sd/junos_targets.yml
- targets:
- '192.168.1.1'
labels:
site: 'DC1'
model: 'SRX220H2'
vendor: 'juniper'
Reload Prometheus to start scraping the instance through the SNMP exporter.
systemctl reload prometheus
You should now see the targets in prometheus under /targets on the web interface.
Import the dashboard to your Grafana instance to view metrics.
Macros exist for interface types and names. There is also a macro to specify the instance.
https://grafana.com/grafana/dashboards/23625-junos-12-3-snmp-prometheus/