RouterOS Monitoring with Grafana
RouterOS Monitoring with Grafana
Section titled “RouterOS Monitoring with Grafana”Overview
Section titled “Overview”Grafana is an open-source dashboarding platform that can visualize RouterOS metrics collected via SNMP. Two common collection pipelines are available:
| Pipeline | Best For |
|---|---|
| Prometheus + SNMP Exporter | Existing Prometheus infrastructure; metric scraping model |
| Telegraf + InfluxDB | Time-series push model; simpler SNMP configuration |
Both approaches require SNMP enabled on RouterOS and a Linux host to run the collection stack. The same Grafana instance can consume data from either backend.
RouterOS Prerequisites
Section titled “RouterOS Prerequisites”Enable SNMP before configuring any Grafana pipeline. SNMPv2c is used in the examples below; SNMPv3 is strongly recommended for production — see SNMPv3 Configuration and Monitoring Integration for the full SNMPv3 setup.
SNMPv2c (Lab / Quick Start)
Section titled “SNMPv2c (Lab / Quick Start)”# Enable SNMP
# Restrict community to the Grafana collector host/snmp community set [find name=public] \ addresses=10.10.10.0/24 \ read-access=yes \ write-access=noSNMPv3 (Production)
Section titled “SNMPv3 (Production)”/snmp community add \ name=grafana \ security=private \ authentication-protocol=SHA1 \ authentication-password="AuthPass123!" \ encryption-protocol=AES \ encryption-password="PrivPass123!" \ addresses=10.10.10.10/32 \ read-access=yes \ write-access=noFirewall Rule
Section titled “Firewall Rule”Allow SNMP polling from the collector host only:
/ip firewall filter add \ chain=input protocol=udp dst-port=161 \ src-address=10.10.10.10/32 \ action=accept comment="SNMP polling from Grafana collector"
/ip firewall filter add \ chain=input protocol=udp dst-port=161 \ action=drop comment="Drop all other SNMP"Approach 1: Prometheus + SNMP Exporter + Grafana
Section titled “Approach 1: Prometheus + SNMP Exporter + Grafana”Architecture
Section titled “Architecture”RouterOS ──(SNMP UDP 161)──► SNMP Exporter ──(HTTP :9116)──► Prometheus ──► GrafanaPrometheus scrapes the SNMP Exporter at a configured interval. The exporter translates SNMP OID values into Prometheus metrics. Grafana queries Prometheus to render dashboards.
1. Install SNMP Exporter
Section titled “1. Install SNMP Exporter”Download the latest release from the Prometheus GitHub releases page and extract to a system directory:
# Create a dedicated usersudo useradd --no-create-home --shell /bin/false snmp_exporter
# Download and extract (check https://github.com/prometheus/snmp_exporter/releases for latest)wget https://github.com/prometheus/snmp_exporter/releases/download/v0.26.0/snmp_exporter-0.26.0.linux-amd64.tar.gztar xzf snmp_exporter-0.26.0.linux-amd64.tar.gzsudo mv snmp_exporter-0.26.0.linux-amd64/snmp_exporter /usr/local/bin/sudo chown snmp_exporter:snmp_exporter /usr/local/bin/snmp_exporter2. Configure snmp.yml
Section titled “2. Configure snmp.yml”Create /etc/snmp_exporter/snmp.yml with a MikroTik module. The following covers the most useful metrics:
auths: public_v2: community: public security_level: noAuthNoPriv auth_protocol: MD5 priv_protocol: DES version: 2
grafana_v3: security_level: authPriv username: grafana password: AuthPass123! auth_protocol: SHA priv_protocol: AES priv_password: PrivPass123! version: 3
modules: mikrotik: walk: - 1.3.6.1.2.1.1 # System info (sysDescr, sysUpTime, sysName) - 1.3.6.1.2.1.2.2 # Interface table (ifDescr, ifOperStatus, ifSpeed) - 1.3.6.1.2.1.31.1.1 # IF-MIB extended (64-bit counters, ifAlias) - 1.3.6.1.4.1.14988.1.1.1 # MikroTik wireless (signal, noise, CCQ) - 1.3.6.1.4.1.14988.1.1.3 # MikroTik health (voltage, temperature) - 1.3.6.1.4.1.14988.1.1.7 # MikroTik CPU usage - 1.3.6.1.4.1.14988.1.1.8 # MikroTik memory usage metrics: - name: sysUpTime oid: 1.3.6.1.2.1.1.3.0 type: gauge help: System uptime in hundredths of a second - name: ifHCInOctets oid: 1.3.6.1.2.1.31.1.1.1.6 type: counter help: Inbound octets (64-bit) indexes: - labelname: ifIndex type: gauge lookups: - labels: [ifIndex] labelname: ifName oid: 1.3.6.1.2.1.31.1.1.1.1 type: DisplayString - name: ifHCOutOctets oid: 1.3.6.1.2.1.31.1.1.1.10 type: counter help: Outbound octets (64-bit) indexes: - labelname: ifIndex type: gauge lookups: - labels: [ifIndex] labelname: ifName oid: 1.3.6.1.2.1.31.1.1.1.1 type: DisplayString - name: ifOperStatus oid: 1.3.6.1.2.1.2.2.1.8 type: gauge help: Interface operational status (1=up, 2=down) indexes: - labelname: ifIndex type: gauge lookups: - labels: [ifIndex] labelname: ifName oid: 1.3.6.1.2.1.31.1.1.1.1 type: DisplayString3. Run SNMP Exporter as a Service
Section titled “3. Run SNMP Exporter as a Service”Create /etc/systemd/system/snmp_exporter.service:
[Unit]Description=Prometheus SNMP ExporterAfter=network.target
[Service]User=snmp_exporterExecStart=/usr/local/bin/snmp_exporter --config.file=/etc/snmp_exporter/snmp.ymlRestart=on-failure
[Install]WantedBy=multi-user.targetsudo systemctl daemon-reloadsudo systemctl enable --now snmp_exporter# Verifycurl http://localhost:9116/metrics | head -204. Configure Prometheus Scrape Job
Section titled “4. Configure Prometheus Scrape Job”Add a scrape job to /etc/prometheus/prometheus.yml:
scrape_configs: - job_name: mikrotik_snmp static_configs: - targets: - 192.168.1.1 # Router IP - 192.168.1.2 # Additional routers metrics_path: /snmp params: module: [mikrotik] auth: [public_v2] # or grafana_v3 for SNMPv3 relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: localhost:9116 # SNMP Exporter addressReload Prometheus:
sudo systemctl reload prometheusVerify targets are up in the Prometheus UI at http://prometheus-host:9090/targets.
5. Add Prometheus Datasource in Grafana
Section titled “5. Add Prometheus Datasource in Grafana”- In Grafana, navigate to Connections → Data Sources → Add data source.
- Select Prometheus.
- Set the URL to your Prometheus server (e.g.,
http://localhost:9090). - Click Save & Test.
6. Import a MikroTik Dashboard
Section titled “6. Import a MikroTik Dashboard”Several community dashboards work well with RouterOS metrics via SNMP Exporter:
| Dashboard ID | Description |
|---|---|
10950 | MikroTik: traffic, uptime, CPU, memory (wide interface coverage) |
14857 | MikroTik SNMP: interface bandwidth with 64-bit counters |
To import: Dashboards → New → Import, enter the dashboard ID, select the Prometheus datasource, and click Import.
Approach 2: Telegraf + InfluxDB + Grafana
Section titled “Approach 2: Telegraf + InfluxDB + Grafana”Architecture
Section titled “Architecture”RouterOS ──(SNMP UDP 161)──► Telegraf ──(HTTP API)──► InfluxDB ──► GrafanaTelegraf polls RouterOS directly via SNMP and writes results to InfluxDB. Grafana queries InfluxDB using Flux or InfluxQL.
1. Install Telegraf
Section titled “1. Install Telegraf”# Debian/Ubuntuwget -q https://repos.influxdata.com/influxdb.key -O- | sudo apt-key add -echo "deb https://repos.influxdata.com/ubuntu focal stable" | sudo tee /etc/apt/sources.list.d/influxdb.listsudo apt-get update && sudo apt-get install -y telegraf2. Configure Telegraf SNMP Input
Section titled “2. Configure Telegraf SNMP Input”Add to /etc/telegraf/telegraf.d/mikrotik.conf:
[[inputs.snmp]] ## Target routers agents = ["udp://192.168.1.1:161", "udp://192.168.1.2:161"]
## SNMPv2c version = 2 community = "public"
## SNMPv3 (uncomment to use instead) # version = 3 # sec_name = "grafana" # auth_protocol = "SHA" # auth_password = "AuthPass123!" # priv_protocol = "AES" # priv_password = "PrivPass123!" # sec_level = "authPriv"
## Polling interval interval = "60s" timeout = "10s" retries = 3
## System info [[inputs.snmp.field]] name = "hostname" oid = "RFC1213-MIB::sysName.0" is_tag = true
[[inputs.snmp.field]] name = "uptime" oid = "DISMAN-EXPRESSION-MIB::sysUpTimeInstance"
## CPU usage (MikroTik enterprise OID) [[inputs.snmp.field]] name = "cpu_usage" oid = "1.3.6.1.4.1.14988.1.1.7.1.0"
## Memory (MikroTik enterprise OID) [[inputs.snmp.field]] name = "mem_total" oid = "1.3.6.1.4.1.14988.1.1.8.1.0"
[[inputs.snmp.field]] name = "mem_used" oid = "1.3.6.1.4.1.14988.1.1.8.2.0"
## Interface traffic (64-bit counters, one row per interface) [[inputs.snmp.table]] name = "interface_traffic" inherit_tags = ["hostname"] oid = "IF-MIB::ifXTable"
[[inputs.snmp.table.field]] name = "name" oid = "IF-MIB::ifName" is_tag = true
[[inputs.snmp.table.field]] name = "in_octets" oid = "IF-MIB::ifHCInOctets"
[[inputs.snmp.table.field]] name = "out_octets" oid = "IF-MIB::ifHCOutOctets"
[[inputs.snmp.table.field]] name = "in_errors" oid = "IF-MIB::ifInErrors"
[[inputs.snmp.table.field]] name = "out_errors" oid = "IF-MIB::ifOutErrors"
[[inputs.snmp.table.field]] name = "oper_status" oid = "IF-MIB::ifOperStatus"Configure Telegraf output to InfluxDB:
[[outputs.influxdb_v2]] urls = ["http://localhost:8086"] token = "$INFLUX_TOKEN" organization = "my-org" bucket = "routeros"Start Telegraf:
sudo systemctl enable --now telegrafsudo journalctl -u telegraf -f # watch for errors3. Add InfluxDB Datasource in Grafana
Section titled “3. Add InfluxDB Datasource in Grafana”- Navigate to Connections → Data Sources → Add data source.
- Select InfluxDB.
- Set Query Language to Flux.
- Set URL to
http://localhost:8086. - Under InfluxDB Details: enter your Organization, Token, and default Bucket (
routeros). - Click Save & Test.
4. Example Grafana Panels (Flux Queries)
Section titled “4. Example Grafana Panels (Flux Queries)”Interface bandwidth (bits per second):
from(bucket: "routeros") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "interface_traffic") |> filter(fn: (r) => r._field == "in_octets" or r._field == "out_octets") |> filter(fn: (r) => r.name == "ether1") |> derivative(unit: 1s, nonNegative: true) |> map(fn: (r) => ({r with _value: r._value * 8.0}))CPU utilization:
from(bucket: "routeros") |> range(start: v.timeRangeStart, stop: v.timeRangeStop) |> filter(fn: (r) => r._measurement == "snmp" and r._field == "cpu_usage")Key MikroTik OIDs Reference
Section titled “Key MikroTik OIDs Reference”These OIDs are useful when building custom SNMP Exporter modules or Telegraf field configurations:
| OID | Name | Description |
|---|---|---|
1.3.6.1.2.1.1.3.0 | sysUpTime | Uptime in hundredths of a second |
1.3.6.1.2.1.2.2.1.8 | ifOperStatus | Interface up (1) / down (2) |
1.3.6.1.2.1.31.1.1.1.6 | ifHCInOctets | Inbound bytes, 64-bit |
1.3.6.1.2.1.31.1.1.1.10 | ifHCOutOctets | Outbound bytes, 64-bit |
1.3.6.1.4.1.14988.1.1.1.1 | MikroTik wireless signal strength | Per-interface |
1.3.6.1.4.1.14988.1.1.3.1.0 | MikroTik voltage | Board voltage |
1.3.6.1.4.1.14988.1.1.3.10.0 | MikroTik temperature | Board temperature (°C) |
1.3.6.1.4.1.14988.1.1.7.1.0 | MikroTik CPU usage | CPU load percentage |
1.3.6.1.4.1.14988.1.1.8.1.0 | MikroTik total memory | Bytes |
1.3.6.1.4.1.14988.1.1.8.2.0 | MikroTik free memory | Bytes |
Choosing Between the Two Approaches
Section titled “Choosing Between the Two Approaches”| Factor | Prometheus + SNMP Exporter | Telegraf + InfluxDB |
|---|---|---|
| Scrape model | Pull (Prometheus scrapes exporter) | Push (Telegraf writes to InfluxDB) |
| Query language | PromQL | Flux / InfluxQL |
| Existing stack | Works if Prometheus already present | Works if InfluxDB already present |
| Configuration complexity | Higher (snmp.yml module + Prometheus job) | Moderate (single Telegraf config) |
| Alerting | Alertmanager (well-established) | InfluxDB Tasks or Grafana Alerts |
| Multi-device scaling | Excellent (relabeling rules) | Good (multiple agents entries) |
Troubleshooting
Section titled “Troubleshooting”No data in Grafana
Section titled “No data in Grafana”- Confirm SNMP is reachable from the collector host:
Terminal window snmpwalk -v2c -c public 192.168.1.1 1.3.6.1.2.1.1 - For Prometheus: check the SNMP Exporter’s own metrics endpoint:
Terminal window curl "http://localhost:9116/snmp?target=192.168.1.1&module=mikrotik" | grep -v "^#" - For Telegraf: check logs for connection errors:
Terminal window sudo journalctl -u telegraf | grep -i error - Verify no firewall rule is dropping UDP 161 on the router:
/ip firewall filter print where dst-port=161
Counter values are not incrementing
Section titled “Counter values are not incrementing”- Confirm the OID returns numeric data:
Terminal window snmpget -v2c -c public 192.168.1.1 1.3.6.1.2.1.31.1.1.1.6.1 - Check that
read-access=yesis set on the SNMP community.
Interface names missing from metrics
Section titled “Interface names missing from metrics”- Verify the IF-MIB walk is returning
ifNamedata:Terminal window snmpwalk -v2c -c public 192.168.1.1 1.3.6.1.2.1.31.1.1.1.1
Related Resources
Section titled “Related Resources”- SNMP — SNMP basic configuration reference
- SNMPv3: Configuration and Monitoring Integration — SNMPv3 setup and integration with LibreNMS, Zabbix, PRTG
- Traffic Flow (NetFlow / IPFIX) — Export flows to Grafana via Elasticsearch or nfdump
- System Health and Resource Monitoring — Built-in resource monitoring