MikroTik Monitoring with Prometheus and Grafana: Export, Dashboards, and Alerting
A practical SNMPv3 collection path, interface queries, dashboard design, and alerts that distinguish device symptoms from monitoring failures.
An ISP or municipal network needs more than a screen of green devices. Operators need to know whether a circuit is approaching capacity, an interface is accumulating errors, or a monitoring failure is hiding an outage. Prometheus and Grafana can turn MikroTik interface counters into useful history, provided collection, labels, thresholds, and notification routing are designed together.
This walkthrough uses SNMPv3, the official Prometheus SNMP exporter, Prometheus recording and alert rules, and Grafana dashboards. It is a baseline for a controlled management network, not a deployment onto your routers. Validate it against your RouterOS release, hardware, exporter configuration, and operational requirements before production use.
1. Understand the Collection Path
MikroTik router -- SNMPv3 / UDP 161 --> SNMP exporter
Prometheus -- HTTP scrape / TCP 9116 --> SNMP exporter
Grafana -- Prometheus HTTP API / TCP 9090 --> Prometheus
Prometheus -- alert delivery --> Alertmanager --> notification receiverThe arrows above identify protocol relationships; SNMP polling is initiated by the exporter toward the router. Prometheus requests /snmp with a target, module, and authentication profile. The exporter polls that device and returns metrics. Its separate /metrics endpoint describes the exporter process. Grafana queries stored time series; it does not replace collection. See the multi-target exporter pattern.
The examples place exporter, Prometheus, Grafana, and Alertmanager on one Linux monitoring host. Loopback addresses below depend on that arrangement. In containers, localhost refers to the individual container unless a shared network namespace is explicitly used; substitute service names and approved private networking. Keep all service interfaces private or protected with appropriate authentication and TLS. Limit exporter HTTP access and its outbound reach: a target-parameter endpoint should not become an unrestricted network probe.
2. Prepare Read-Only SNMPv3 on RouterOS
Assume router management address 10.20.0.1 and exporter source address 10.20.0.10. Replace both. Review existing monitoring dependencies before changing communities. Use separate strong authentication and privacy secrets, entered through your approved secure administration process. The following requires a RouterOS release supporting SHA256 and AES; inspect local command help first. MikroTik documents SNMPv3 settings and OID discovery.
/snmp community set [find where name="public"] read-access=no write-access=no
/snmp community add name=noc-v3 addresses=10.20.0.10/32 \
security=private read-access=yes write-access=no \
authentication-protocol=SHA256 encryption-protocol=AES \
authentication-password="REPLACE_WITH_AUTH_SECRET" \
encryption-password="REPLACE_WITH_PRIVACY_SECRET"
/snmp set enabled=yes
/interface print oidRestrict router input policy to approved collectors over the management path, with correct rule order and return routing. Review IPv6 independently. A source allowlist complements the firewall; it does not replace it. Preserve existing required polling while removing unintended public or write-enabled access. Do not expose UDP 161 to the internet.
3. Export Metrics Without Mixing Up Runtime and Generator Files
Install reviewed, version-pinned releases of snmp_exporter and its matching configuration from the official project. Start with the supplied if_mib module. Keep the shipped snmp.yml at /etc/snmp_exporter/snmp.yml and put this additional authentication profile in /etc/snmp_exporter/auth.yml. Protect both files; the placeholders below must be replaced locally, never with secrets committed to a public repository.
auths:
routeros_v3:
version: 3
username: noc-v3
security_level: authPriv
auth_protocol: SHA256
password: REPLACE_WITH_AUTH_SECRET
priv_protocol: AES
priv_password: REPLACE_WITH_PRIVACY_SECRETsnmp_exporter \
--config.file=/etc/snmp_exporter/snmp.yml \
--config.file=/etc/snmp_exporter/auth.yml \
--web.listen-address=127.0.0.1:9116
# Run this from a second terminal on the monitoring host:
curl --fail --get http://127.0.0.1:9116/snmp \
--data-urlencode target=10.20.0.1 \
--data-urlencode auth=routeros_v3 \
--data-urlencode module=if_mibFor versions supporting multiple configuration files, auth and module names must be unique across those files. Run the service as a dedicated unprivileged account with access only to its required configuration. Check that the returned metrics include ifHCInOctets, ifHCOutOctets, ifAdminStatus, and ifOperStatus before building queries.
For CPU, memory, environmental sensors, or vendor-specific measurements, inspect supported OIDs and use the SNMP exporter generator with the required standard and MikroTik MIBs. generator.yml describes collection; the generated snmp.yml is the runtime configuration. Preserve generator source and release versions so a rebuild is reproducible. Do not paste a generator walk list into a runtime module and expect metric definitions to appear automatically. Available sensors and OID support vary by device.
4. Configure Prometheus Scraping and Target Labels
Save the following as /etc/prometheus/prometheus.yml. The 30-second interval and 20-second timeout are starting assumptions. Measure collection duration and router CPU before scaling. Follow the Prometheus configuration reference for the deployed version.
global:
scrape_interval: 30s
evaluation_interval: 30s
rule_files:
- /etc/prometheus/rules/mikrotik.yml
alerting:
alertmanagers:
- static_configs:
- targets: ["127.0.0.1:9093"]
scrape_configs:
- job_name: mikrotik_snmp
scrape_timeout: 20s
metrics_path: /snmp
params:
auth: [routeros_v3]
module: [if_mib]
static_configs:
- targets: ["10.20.0.1"]
labels:
site: dc-west
device: edge-01
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
- job_name: snmp_exporter
static_configs:
- targets: ["127.0.0.1:9116"]The relabeling preserves the router address as instance while directing HTTP traffic to the exporter. Keep labels consistent and low in cardinality: site, device, and stable interface identity are useful. Avoid customer secrets or frequently changing values in labels. Interface indexes can change after configuration or hardware changes; verify how names and aliases are attached to the collected series.
5. Query Counters as Rates, Not Raw Bandwidth
Use high-capacity octet counters when supported. Octets are bytes, so multiply a per-second rate by eight for bits per second. Calculate rate before aggregation so resets are handled per series. The PromQL function reference explains rate behavior. The following assumes the if_mib output includes ifName labels; confirm that in your exporter response.
# Receive bits per second by interface
8 * rate(ifHCInOctets{job="mikrotik_snmp",instance="10.20.0.1"}[5m])
# Transmit bits per second by interface
8 * rate(ifHCOutOctets{job="mikrotik_snmp",instance="10.20.0.1"}[5m])
# Receive errors per second; investigate alongside discards and traffic
rate(ifInErrors{job="mikrotik_snmp",instance="10.20.0.1"}[5m])
# Scrape success: 1 = successful scrape; 0 = failed scrape
up{job="mikrotik_snmp"}A five-minute average smooths bursts; it does not show instantaneous peak demand. A fast copper interface can carry a slower contracted service, and a radio’s negotiated Ethernet speed is not its RF capacity. For an illustrative 200 Mbps service, compare that interface’s rate with 200,000,000 bits/s rather than a 1 Gbps port speed. Monitor receive and transmit utilization separately on full-duplex links. For vector division or joins, make matching labels explicit and confirm uniqueness using the PromQL operator reference.
6. Build Grafana Panels That Answer Operational Questions
Add the built-in Prometheus data source using the URL reachable from the Grafana server. For this same-host example, use http://127.0.0.1:9090. In container deployments, use the Prometheus service address instead. Test the connection before importing a dashboard. See Grafana’s data-source configuration guide.
- Availability: show scrape success by site and device, with a separate exporter-health panel.
- Traffic: plot receive and transmit bit rates, with bits/second units and legends such as {{device}} / {{ifName}}.
- Interface state: show administrative and operational state together; a deliberately disabled port is different from an enabled port that is down.
- Quality: show errors and discards with traffic, plus annotated maintenance events and configuration changes.
- Capacity: use documented service capacity and separately verified radio/backhaul limits, rather than assuming every link has its Ethernet port’s capacity.
Add site and device selectors using labels actually present in the series. Use Grafana’s $__rate_interval for interactive rate panels where appropriate; fixed server-side rules need fixed windows. Confirm units, timezone, minimum interval, and missing-data presentation. A panel with no matching series should not look like healthy zero traffic. Treat community dashboards as starting layouts: check each metric and label against your collector before relying on a panel.
7. Create Alerts With Clear Meaning and Ownership
Save this example as /etc/prometheus/rules/mikrotik.yml. It uses Prometheus-managed rules; Grafana-managed alerts are an alternative, not a requirement to duplicate every rule. Review Prometheus alert rule semantics before selecting pending periods and severity.
groups:
- name: mikrotik-baseline
rules:
- alert: MikroTikSNMPScrapeFailed
expr: up{job="mikrotik_snmp"} == 0
for: 3m
labels:
severity: warning
annotations:
summary: "SNMP scrape failed for {{ $labels.device }}"
description: "Check router reachability, SNMP access, credentials, exporter health, and the management path."
- alert: SNMPExporterUnavailable
expr: up{job="snmp_exporter"} == 0
for: 2m
labels:
severity: critical
annotations:
summary: "SNMP exporter cannot be scraped"
- alert: MikroTikRequiredInterfaceDown
expr: |
(ifOperStatus{job="mikrotik_snmp",ifName="ether1"} == 2)
and on (instance, ifIndex)
(ifAdminStatus{job="mikrotik_snmp",ifName="ether1"} == 1)
for: 2m
labels:
severity: warning
annotations:
summary: "Required interface {{ $labels.ifName }} is down on {{ $labels.device }}"Replace ether1 with an inventory-approved required interface selector. Confirm that each job/instance/interface identity is unique; the join assumes one ifIndex per router for this job. The state rule intentionally catches operational down, not every other IF-MIB state. Add other states only where they have a defined operational meaning. A failed SNMP scrape does not prove the router itself is down: authentication failures, timeouts, and an exporter failure can all produce that symptom.
The up series also disappears when a target is removed from discovery. Maintain an expected-target inventory or independent absent-series checks. Monitor Prometheus and notification delivery independently; a monitoring host cannot reliably notify you about its own complete failure. Suppress downstream symptom notifications during confirmed collector incidents and maintenance using reviewed routing, silences, or inhibition policies.
8. Route Notifications and Test the Whole Chain
The following Alertmanager example sends alerts to an internal webhook. It is a template: replace the URL with a real approved receiver and configure required authentication and TLS. Do not leave the example receiver in a production configuration. Review Alertmanager routing and receiver configuration.
route:
receiver: noc-webhook
group_by: [alertname, site]
group_wait: 30s
group_interval: 5m
repeat_interval: 4h
receivers:
- name: noc-webhook
webhook_configs:
- url: https://alerts.example.net/prometheus
send_resolved: trueAssign a destination and response owner to each actionable alert. Include a runbook explaining the first checks, escalation, and recovery verification. A resolved notification matters: test it as well as the initial firing message. Grouping should reduce duplicate messages without hiding the site or device that needs attention.
promtool check config /etc/prometheus/prometheus.yml
promtool check rules /etc/prometheus/rules/mikrotik.yml
amtool check-config /etc/alertmanager/alertmanager.ymlThese checks validate configuration, not live network behavior. After a controlled reload or restart through your service manager, verify target status and samples in Prometheus. Exercise a lab scrape failure, a required interface down state, a collector outage, and recovery. Add promtool rule tests for your own thresholds, labels, and pending periods. Confirm that a real notification reaches the intended receiver; an alert visible in Grafana is not proof of delivery.
9. Scale Collection Without Creating New Blind Spots
Begin with a pilot across representative devices and busy interfaces. Track scrape duration, sample counts, collector resources, and router load. Large walks, short intervals, overlapping modules, and a high interface count can turn monitoring into avoidable work on the device. Collect vendor-specific or expensive tables only when they answer an operational question.
Plan retention and disk capacity from measured ingestion, then review series growth when enabling more interfaces or labels. Distributed collectors can reduce dependence on a single WAN path, but they also need consistent configuration, secret rotation, and defined ownership. Keep logs, flow telemetry, and active service probes alongside metrics where needed: interface counters alone do not reveal every application failure, route leak, or security incident.
Frequently Asked Questions
Does MikroTik export Prometheus metrics directly in this design?
No. RouterOS answers SNMP requests. The SNMP exporter translates those responses into metrics Prometheus can scrape. Vendor API exporters are another approach, but their permissions, metric names, and compatibility require separate review.
Can this monitor CPU, temperature, BGP, or optical diagnostics?
Potentially, where supported OIDs or another appropriate collector exist. Verify the device, software, MIB, units, and exporter definitions. The baseline if_mib configuration here is for interface monitoring and does not promise those additional metrics.
Will these alerts prove that a circuit is down?
They establish specific observations: a scrape failed, an exporter is unavailable, or a selected interface is administratively up and operationally down. Correlate those with independent reachability and service tests before declaring a wider outage.
Build Monitoring Your Operations Team Can Use
Link Technologies, Inc. can help plan MikroTik monitoring, standardize device and interface inventory, review collection scope, and turn measurements into dashboards and actionable operating procedures. Engagement scope and ongoing support responsibilities are defined for your environment.
Discuss Your Monitoring Requirementsmulti-target exporter pattern
MikroTik documents SNMPv3 settings and OID discovery
official project
SNMP exporter generator
Prometheus configuration reference
PromQL function reference
PromQL operator reference
Grafana’s data-source configuration guide
Prometheus alert rule semantics
Alertmanager routing and receiver configuration
promtool rule tests
Link Technologies, Inc.
IT Infrastructure • Wireless • Fiber • Hosting • Cloud Services
shop.linktechs.net • sales@linktechs.net • 314-735-0270
Leave your comment