From ddbb23ea609e9843d94f0618265eac4b6b471cca Mon Sep 17 00:00:00 2001 From: Leon Morten Richter Date: Sat, 10 Jul 2021 14:25:37 +0200 Subject: [PATCH] Initial commit with mikrotik-exporter --- .env | 1 + .vscode/settings.json | 6 ++++++ README.md | 37 ++++++++++++++++++++++++++++++++++++ docker-compose.yml | 11 +++++++++++ mikrotik_exporter/config.yml | 6 ++++++ prometheus/prometheus.yml | 0 6 files changed, 61 insertions(+) create mode 100644 .env create mode 100644 .vscode/settings.json create mode 100644 README.md create mode 100644 docker-compose.yml create mode 100644 mikrotik_exporter/config.yml create mode 100644 prometheus/prometheus.yml diff --git a/.env b/.env new file mode 100644 index 0000000..ac90473 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +CONFIG_FILE=/config/config.yml diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7acc4c1 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "cSpell.words": [ + "grafana", + "mikrotik" + ] +} \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..931ec05 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# Monitor your Mikrotik router with Prometheus and Grafana + +Over the past years I replaced all my networking gear with Mikrotik devices. Nothing compares to Mikrotik in terms of price, features, performance and reliability. I absolutely love WinBox for management, but sometimes I miss some fancy charts and graphs. Luckily, RouterOS comes with a REST-API that can be used to query arbitrary data from the device. + +## Setup + +- Router running RouterOS 7.x.x +- Raspberry Pi 4 with 2 gb RAM + +## Installation + +## Mikrotik Router +At first you need to prepare your router. + +Create a group on the device that has API and read-only access: + +`/user group add name=prometheus policy=api,read,winbox,test` + +Create a user that is part of the group: + +`/user add name=prometheus group=prometheus password=TOP_SECRET` + + +## Prepare Raspi + +Install Python and pip: + +`sudo apt install python3-dev python3 python3-pip -y` + +Install Docker + Docker-compose + +```bash +curl -sSL https://get.docker.com | sh +sudo usermod -aG docker ubuntu +sudo pip3 install docker-compose +sudo systemctl enable docker +``` \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..1d784a0 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3.9" + +services: + mikrotik_exporter: + image: nshttpd/mikrotik-exporter-linux-arm64:1.0.12-DEVEL # Change this depending on your version and/or if you built the image locally + volumes: + - './mikrotik_exporter:/config' + env_file: .env + ports: + - 9436:9436 + restart: unless-stopped \ No newline at end of file diff --git a/mikrotik_exporter/config.yml b/mikrotik_exporter/config.yml new file mode 100644 index 0000000..f2b46a2 --- /dev/null +++ b/mikrotik_exporter/config.yml @@ -0,0 +1,6 @@ +devices: + - name: Chateau + address: 192.168.0.1 + user: prometheus + password: TOP_SECRET + \ No newline at end of file diff --git a/prometheus/prometheus.yml b/prometheus/prometheus.yml new file mode 100644 index 0000000..e69de29