安装Prometheus SNMP Exporter
-
下载snmp_exporter
https://github.com/prometheus/snmp_exporter/releases
找个合适的下载就行 -
配置snmp.yml
根据routeos设备的snmp配置更改
auths: public_v1: community: public #这个为name security_level: noAuthNoPriv auth_protocol: MD5 #检查 priv_protocol: DES #检查 version: 1 public_v2: community: public #这个为name security_level: noAuthNoPriv auth_protocol: MD5 #检查 priv_protocol: DES #检查 version: 2
-
配置prometheus.yaml
scrape_configs: - job_name: 'snmp' static_configs: - targets: - 192.168.1.100 #SNMP device metrics_path: /snmp params: #module: [mikrotik] module: [if_mib] relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: <your-address>:9116 # The SNMP exporter's real hostname:port.
-
启动snmp_exporter后登录prometheus查看状态,为up即ok
问题:
-
snmp_exporter状态为up,但是查不到数据
先点击endpoint看一下,确认没有数据
我的机器是mikrotik,所以我用的是mikrotik,但是不知道为什么这个模板查不到数据。
使用snmpwalk先看下if_mib通用模板有没有数据snmpwalk -v2c -c public ¥{ROUTER_IP} 1.3.6.1.2.1.2.2
有的话在prometheus中切换这个模板,再重新加载配置即可