You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

github.com/psolru/mikrotik-exporter

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/psolru/mikrotik-exporter

v1.3.0
Source
Go
Version published
Created
Source

CI Docker Publish Go Report Docker Pulls

prometheus-mikrotik

tl;dr - prometheus exporter for mikrotik devices

This is still a work in progress .. consider master at the moment as a preview release.

Description

A Prometheus Exporter for Mikrotik devices. Can be configured to collect metrics from a single device or multiple devices. Single device monitoring can be configured all on the command line. Multiple devices require a configuration file. A user will be required that has read-only access to the device configuration via the API.

Because of some breaking changes in the ROS API with ROS7 currently this exporter mainly aims to be compatible with ROS7. Some of the metrics might not work on ROS6.

Currently the exporter supports collecting these groups of metrics:

  • interface
  • resource
  • bgp session
  • dhcp lease
  • dhcp ipv6 lease
  • firmware
  • health
  • ip routes
  • ethernet
  • poe
  • ip pool
  • sfp
  • wlan stations
  • capsman
  • wlan
  • ipsec
  • ospf neighbors
  • lte
  • netwatch
  • conntrack
  • bridge hosts
  • wireguard peers

Mikrotik Config

Create a user on the device that has API and read-only access.

/user group add name=prometheus policy=api,read,winbox

If lte is enabled it requires also the test policy.

/user group add name=prometheus policy=api,read,winbox,test

Create the user to access the API via.

/user add name=prometheus group=prometheus password=changeme

Single Device

./mikrotik-exporter -address 10.10.0.1 -device my_router -password changeme -user prometheus

where address is the address of your router. device is the label name for the device in the metrics output to prometheus. The username and password are the ones you created for the exporter to use to access the API.

User and password flags can be set with the MIKROTIK_USER and MIKROTIK_PASSWORD environment variables, respectively.

MIKROTIK_USERNAME=prometheus
MIKROTIK_PASSWORD=changeme
./mikrotik-exporter -address 10.10.0.1 -device my_router

Config File

./mikrotik-exporter -config-file config.yml

where config-file is the path to a config file in YAML format.

example config
devices:
  - name: my_router
    address: 10.10.0.1
    username: prometheus
    password: changeme
    features:
      bgp: true
      dhcp: true
      dhcp_leases: true
      ip_pools: true
      wlan: true
      wlan_stations: true
      bridge_hosts: true
      wireguard: true
  - name: my_second_router
    address: 10.10.0.2
    port: 8999
    username: prometheus2
    password: password_to_second_router
    client:
      enable_tls: true
      insecure_tls_skip_verify: true
  - name: routers_srv_dns
    dns_record:
      record: _mikrotik._udp.example.com
    username: prometheus
    password: password_to_all_dns_routers
  - name: routers_srv_custom_dns
    dns_record:
      record: _mikrotik2._udp.example.com
      server:
        address: 1.1.1.1
        port: 53
    username: prometheus
    password: password_to_all_dns_routers

client:
  dial_timeout: 1s

features:
  firmware: true
  routes: true
  ethernet: true
  ipsec: true
  ospf_neighbors: true
  conntrack: true

If you add a devices with the dns_record parameter instead of address the exporter will perform a DNS query to obtain the SRV record and discover the devices dynamically. Also, you can specify a DNS server to use on the query.

example output
mikrotik_interface_tx_byte{address="10.10.0.1",interface="ether2",name="my_router"} 1.4189902583e+10
mikrotik_interface_tx_byte{address="10.10.0.1",interface="ether3",name="my_router"} 2.263768666e+09
mikrotik_interface_tx_byte{address="10.10.0.1",interface="ether4",name="my_router"} 1.6572299e+08
mikrotik_interface_tx_byte{address="10.10.0.1",interface="ether5",name="my_router"} 1.66711315e+08
mikrotik_interface_tx_byte{address="10.10.0.1",interface="ether6",name="my_router"} 1.0026481337e+10
mikrotik_interface_tx_byte{address="10.10.0.1",interface="ether7",name="my_router"} 3.18354425e+08
mikrotik_interface_tx_byte{address="10.10.0.1",interface="ether8",name="my_router"} 1.86405031e+08

FAQs

Package last updated on 19 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts