# igorkha/grafana-mikrotik architecture

> Architecture diagram of the GitHub repository igorkha/grafana-mikrotik, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/igorkha/grafana-mikrotik
- Repository: https://github.com/igorkha/grafana-mikrotik

## Overview

#### 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`](https://github.com/igorkha/grafana-mikrotik/blob/master/docker-compose.yml) (Docker Compose), [`grafana/provisioning/dashboards/dashboard.yml`](https://github.com/igorkha/grafana-mikrotik/blob/master/grafana/provisioning/dashboards/dashboard.yml) (Dashboard provisioning), [`grafana/provisioning/dashboards/Mikrotik-snmp-prometheus.json`](https://github.com/igorkha/grafana-mikrotik/blob/master/grafana/provisioning/dashboards/Mikrotik-snmp-prometheus.json) (MikroTik dashboard), [`run.sh`](https://github.com/igorkha/grafana-mikrotik/blob/master/run.sh) (run.sh)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Deployment"]
  node_run_script["run.sh<br/>lifecycle script<br/>[run.sh]"]
  node_compose["Docker Compose<br/>orchestration<br/>[docker-compose.yml]"]
  node_env["Deploy settings<br/>environment<br/>[.env]"]
end

subgraph group_monitoring["Monitoring Stack"]
  node_snmp_dockerfile["SNMP Exporter image<br/>container build"]
  node_snmp_exporter["SNMP Exporter<br/>metrics translator"]
  node_snmp_config["SNMP modules<br/>exporter config<br/>[snmp.yml]"]
  node_snmp_binary["Standalone exporter<br/>manual runtime"]
  node_prom_config["Scrape configuration<br/>Prometheus config<br/>[prometheus.yml]"]
  node_prometheus[("Prometheus<br/>metrics store")]
  node_prom_data[("Time-series data<br/>local storage")]
end

subgraph group_grafana["Grafana Provisioning"]
  node_datasource["Prometheus datasource<br/>Grafana provisioning<br/>[datasource.yml]"]
  node_dashboard_loader["Dashboard provisioning<br/>Grafana provisioning<br/>[dashboard.yml]"]
  node_dashboard["MikroTik dashboard<br/>Grafana dashboard"]
  node_grafana_service["Grafana<br/>visualization service"]
end

node_router{{"MikroTik RouterOS<br/>SNMP target"}}

node_run_script -->|"manages"| node_compose
node_env -.->|"supplies settings"| node_compose
node_compose -->|"runs"| node_snmp_exporter
node_compose -->|"runs"| node_prometheus
node_compose -->|"runs"| node_grafana_service
node_snmp_dockerfile -->|"builds"| node_snmp_exporter
node_snmp_config -->|"configures mikrotik module"| node_snmp_exporter
node_snmp_binary -.->|"alternative deployment"| node_snmp_exporter
node_prom_config -->|"configures scrape"| node_prometheus
node_prometheus -->|"scrapes /snmp"| node_snmp_exporter
node_snmp_exporter -->|"polls SNMP/UDP"| node_router
node_snmp_exporter -->|"returns metrics"| node_prometheus
node_prometheus -->|"persists"| node_prom_data
node_datasource -->|"configures"| node_grafana_service
node_dashboard_loader -->|"loads"| node_grafana_service
node_dashboard -->|"defined by"| node_dashboard_loader
node_grafana_service -->|"queries"| node_prometheus
node_grafana_service -->|"renders"| node_dashboard

click node_run_script "https://github.com/igorkha/grafana-mikrotik/blob/master/run.sh"
click node_compose "https://github.com/igorkha/grafana-mikrotik/blob/master/docker-compose.yml"
click node_env "https://github.com/igorkha/grafana-mikrotik/blob/master/.env"
click node_snmp_dockerfile "https://github.com/igorkha/grafana-mikrotik/tree/master/snmp/Dockerfile"
click node_snmp_config "https://github.com/igorkha/grafana-mikrotik/blob/master/snmp/snmp.yml"
click node_snmp_binary "https://github.com/igorkha/grafana-mikrotik/tree/master/snmp/snmp_exporter"
click node_prom_config "https://github.com/igorkha/grafana-mikrotik/blob/master/prometheus/prometheus.yml"
click node_prom_data "https://github.com/igorkha/grafana-mikrotik/tree/master/prometheus/data"
click node_datasource "https://github.com/igorkha/grafana-mikrotik/blob/master/grafana/provisioning/datasources/datasource.yml"
click node_dashboard_loader "https://github.com/igorkha/grafana-mikrotik/blob/master/grafana/provisioning/dashboards/dashboard.yml"
click node_dashboard "https://github.com/igorkha/grafana-mikrotik/blob/master/grafana/provisioning/dashboards/Mikrotik-snmp-prometheus.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_run_script,node_compose,node_env toneBlue
class node_snmp_dockerfile,node_snmp_exporter,node_snmp_config,node_snmp_binary,node_prom_config,node_prometheus,node_prom_data toneAmber
class node_datasource,node_dashboard_loader,node_dashboard,node_grafana_service toneMint
class node_router toneNeutral
```

## Components

### Deployment

- [run.sh](https://github.com/igorkha/grafana-mikrotik/blob/master/run.sh): lifecycle script · Interactive configuration and lifecycle entry point. · `run.sh`
- [Docker Compose](https://github.com/igorkha/grafana-mikrotik/blob/master/docker-compose.yml): orchestration · Defines the Grafana, Prometheus, and SNMP Exporter topology. · `docker-compose.yml`
- [Deploy settings](https://github.com/igorkha/grafana-mikrotik/blob/master/.env): environment · Credentials and deploy-time settings. · `.env`

### Monitoring Stack

- [SNMP Exporter image](https://github.com/igorkha/grafana-mikrotik/tree/master/snmp/Dockerfile): container build · `snmp/Dockerfile`
- **SNMP Exporter**: metrics translator · Exposes /snmp and polls RouterOS with the mikrotik module.
- [SNMP modules](https://github.com/igorkha/grafana-mikrotik/blob/master/snmp/snmp.yml): exporter config · `snmp/snmp.yml`
- [Standalone exporter](https://github.com/igorkha/grafana-mikrotik/tree/master/snmp/snmp_exporter): manual runtime · Alternative non-Compose deployment binary. · `snmp/snmp_exporter`
- [Scrape configuration](https://github.com/igorkha/grafana-mikrotik/blob/master/prometheus/prometheus.yml): Prometheus config · Relabels the router address into the exporter target parameter. · `prometheus/prometheus.yml`
- **Prometheus**: metrics store · Scrapes exporter metrics and serves queries.
- [Time-series data](https://github.com/igorkha/grafana-mikrotik/tree/master/prometheus/data): local storage · `prometheus/data`

### Grafana Provisioning

- [Prometheus datasource](https://github.com/igorkha/grafana-mikrotik/blob/master/grafana/provisioning/datasources/datasource.yml): Grafana provisioning · `grafana/provisioning/datasources/datasource.yml`
- [Dashboard provisioning](https://github.com/igorkha/grafana-mikrotik/blob/master/grafana/provisioning/dashboards/dashboard.yml): Grafana provisioning · `grafana/provisioning/dashboards/dashboard.yml`
- [MikroTik dashboard](https://github.com/igorkha/grafana-mikrotik/blob/master/grafana/provisioning/dashboards/Mikrotik-snmp-prometheus.json): Grafana dashboard · Pre-provisioned RouterOS visualization. · `grafana/provisioning/dashboards/Mikrotik-snmp-prometheus.json`
- **Grafana**: visualization service · Queries Prometheus and renders the dashboard.

### Other components

- **MikroTik RouterOS**: SNMP target · External router exposing SNMP.

## Connections

- 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
