Skip to content

OpenWrt Monitoring with Prometheus & Grafana

Overview

OpenWrt does not run the standard Go node-exporter by default. Instead, it provides a Lua-based exporter that:

  • Is extremely lightweight (router-friendly)
  • Uses its own uhttpd instance
  • Exposes Prometheus metrics over HTTP (commonly on port 9100)
  • Supports system, network, and WiFi client metrics

Installation

# ssh into your OpenWRT router
ssh root@192.168.1.1

# Run the below commands
opkg update

opkg install \
    prometheus-node-exporter-lua \
    prometheus-node-exporter-lua-nat_traffic \
    prometheus-node-exporter-lua-netstat \
    prometheus-node-exporter-lua-openwrt \
    prometheus-node-exporter-lua-wifi \
    prometheus-node-exporter-lua-wifi_stations

Exporter Runtime Model

The exporter runs its own uHTTPd process (not the main LuCI one).

Example process:

/usr/sbin/uhttpd \
  -L /usr/bin/prometheus-node-exporter-lua \
  -p <bind-ip>:9100

This means:

  • Metrics are served at /metrics
  • Port 9100 is valid (unlike the LuCI-based exporter mode)

Configurations

By default, the exporter may bind to the wrong interface IP (e.g. old LAN IP) if you had configured custom vLANs on your router.

Modifying Interfaces & Ports

Make sure the below configs configs are changed so that metrics endpoints are exposed in your right interfaces where the K8s have access to.

Edit:

vi /etc/config/prometheus-node-exporter-lua

Set:

config prometheus-node-exporter-lua 'main'
        option listen_address '0.0.0.0'
        option listen_port '9100'

Restart:

/etc/init.d/prometheus-node-exporter-lua restart

Verify:

etc/init.d/prometheus-node-exporter-lua info
--- (or) ---
ss -lntp | grep 9100

Expected:

0.0.0.0:9100

Verify Metrics Endpoint

From the router:

curl http://localhost:9100/metrics

From another machine:

curl http://<router-ip>:9100/metrics

Prometheus Operator Integration

If you are already running the Prometheus stack with Grafana in K8s like me, you can use the ScrapeConfig CRD which operator porvides.

---
apiVersion: monitoring.coreos.com/v1alpha1
kind: ScrapeConfig
metadata:
  name: openwrt-router
  namespace: monitoring
  labels:
    release: prometheus
spec:
  jobName: OpenWRT
  metricsPath: /metrics
  scrapeInterval: 15s
  staticConfigs:
    - targets:
      - "192.168.1.1:9100"

Grafana Dashboard

Below dashboard provides quite a few insights about the router, network & other useful metrics. Grafana

Dashboard link here. You can install the dashboard using the GrafanaDashboard Grafana operator CRD in K8s.

---
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDashboard
metadata:
  name: opennwrt
  namespace: monitoring
spec:
  resyncPeriod: 12h
  instanceSelector:
    matchLabels:
      grafana.internal/instance: grafana
  datasources:
    - datasourceName: prometheus
      inputName: DS_PROMETHEUS
  url: "https://grafana.com/api/dashboards/18153/revisions/4/download"

Comments