How igorkha/grafana-mikrotik works
Purpose and Deployment Entry Points
This repository is a Docker Compose monitoring stack for MikroTik RouterOS devices via SNMP. It packages SNMP Exporter, Prometheus, and Grafana with a pre-provisioned MikroTik dashboard. Primary entry points are run.sh for interactive configuration/lifecycle actions and docker-compose.yml for direct orchestration.
Stack Orchestration
docker-compose.yml defines the runtime topology: Grafana visualizes metrics, Prometheus stores and queries them, and the SNMP exporter translates MikroTik SNMP responses into Prometheus metrics. .env supplies deploy-time credentials/settings used by the Compose stack.
SNMP Collection Boundary
The SNMP exporter is a dedicated service built from snmp/Dockerfile and configured by snmp/snmp.yml. It is the network-facing boundary to MikroTik devices: Prometheus calls its /snmp endpoint while the exporter queries the configured router target using the mikrotik module.
Prometheus Scrape and Storage
prometheus/prometheus.yml defines the MikroTik scrape job and target IP. Its relabeling converts the configured device address into the exporter target parameter while routing the actual HTTP scrape to the SNMP exporter. Prometheus persists local time-series data under prometheus/data.
Grafana Provisioning and Visualization
Grafana is configured declaratively rather than manually. grafana/provisioning/datasources/datasource.yml connects Grafana to Prometheus, while grafana/provisioning/dashboards/dashboard.yml loads the bundled dashboard. The core dashboard definition is grafana/provisioning/dashboards/Mikrotik-snmp-prometheus.json.
Primary Data Flow
1. A MikroTik router exposes SNMP.
2. Prometheus reads prometheus/prometheus.yml and periodically requests SNMP Exporter metrics.
3. SNMP Exporter uses snmp/snmp.yml to poll the target router and returns Prometheus-format metrics.
4. Prometheus stores the metrics locally.
5. Grafana queries Prometheus through its provisioned datasource and renders the MikroTik dashboard.
Runtime and External Dependencies
The system requires Docker/Docker Compose, network reachability from the SNMP exporter to MikroTik UDP/SNMP, and a RouterOS-compatible SNMP configuration. Material service versions indicated by the project are Grafana 9.0.5, Prometheus 2.37.0, and SNMP Exporter 0.20.0. The included snmp/snmp_exporter binary supports standalone/manual deployment as an alternative to Compose.
Main entry points: docker-compose.yml Docker Compose · dashboard.yml Dashboard provisioning · Mikrotik-snmp-prometheus.json MikroTik dashboard · run.sh run.sh
Components 15
Deployment
- run.sh · Interactive configuration and lifecycle entry point.
run.sh - Docker Compose · Defines the Grafana, Prometheus, and SNMP Exporter topology.
docker-compose.yml - Deploy settings · Credentials and deploy-time settings.
.env
Monitoring Stack
- SNMP Exporter image
snmp/Dockerfile - SNMP Exporter · Exposes /snmp and polls RouterOS with the mikrotik module.
- SNMP modules
snmp/snmp.yml - Standalone exporter · Alternative non-Compose deployment binary.
snmp/snmp_exporter - Scrape configuration · Relabels the router address into the exporter target parameter.
prometheus/prometheus.yml - Prometheus · Scrapes exporter metrics and serves queries.
- Time-series data
prometheus/data
Grafana Provisioning
- Prometheus datasource
grafana/provisioning/datasources/datasource.yml - Dashboard provisioning
grafana/provisioning/dashboards/dashboard.yml - MikroTik dashboard · Pre-provisioned RouterOS visualization.
grafana/provisioning/dashboards/Mikrotik-snmp-prometheus.json - Grafana · Queries Prometheus and renders the dashboard.
Other components
- MikroTik RouterOS · External router exposing SNMP.
Connections 18
- run.sh → Docker Compose: manages
- Deploy settings → Docker Compose: supplies settings
- Docker Compose → SNMP Exporter: runs
- Docker Compose → Prometheus: runs
- Docker Compose → Grafana: runs
- SNMP Exporter image → SNMP Exporter: builds
- SNMP modules → SNMP Exporter: configures mikrotik module
- Standalone exporter → SNMP Exporter: alternative deployment
- Scrape configuration → Prometheus: configures scrape
- Prometheus → SNMP Exporter: scrapes /snmp
- SNMP Exporter → MikroTik RouterOS: polls SNMP/UDP
- SNMP Exporter → Prometheus: returns metrics
- Prometheus → Time-series data: persists
- Prometheus datasource → Grafana: configures
- Dashboard provisioning → Grafana: loads
- MikroTik dashboard → Dashboard provisioning: defined by
- Grafana → Prometheus: queries
- Grafana → MikroTik dashboard: renders