Prometheus autodiscovery for Mikrotik devices
version: "3"
services:
prometheus:
image: prom/prometheus
volumes:
- "./prometheus.yml:/etc/prometheus/prometheus.yml"
- "mikrotik-discovery:/etc/prometheus/mikrotik-discovery"
- "prometheus-data:/prometheus"
# [...]
mndp-autodiscovery:
image: prometheus-mndp-autodiscovery
build: ./prometheus-mndp-autodiscovery # path of git repo
volumes:
- "mikrotik-discovery:/file_sd/"
network_mode: host # required for receiving UDP broadcasts
volumes:
prometheus-data:
mikrotik-discovery:
global:
# [...]
scrape_configs:
- job_name: 'snmp'
metrics_path: /snmp
file_sd_configs:
- files:
- 'mikrotik-discovery/targets.json'
relabel_configs:
- source_labels: [__address__]
target_label: instance
regex: '(^[^-]*-[^.]*).*'
replacement: '$1'
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__address__]
target_label: target
- target_label: __address__
replacement: '[ip or host where snmp-exporter is running]:9116'