Monitoring GL.iNet with Grafana

GL.iNet routers run OpenWRT, which has native Prometheus exporter packages and remote syslog support. This guide covers installing the Lua-based node exporter for metrics and forwarding syslog to Loki via Grafana Alloy — giving you full observability of your GL.iNet router.

Note: This guide is written for GL.iNet routers, but the same steps apply to any router running standard OpenWRT.

Prerequisites

Metrics

Install the Prometheus Exporter

Connect to your router via SSH and install the exporter packages:

BASH
opkg update
opkg install prometheus-node-exporter-lua \
  prometheus-node-exporter-lua-openwrt \
  prometheus-node-exporter-lua-wifi \
  prometheus-node-exporter-lua-wifi_stations \
  prometheus-node-exporter-lua-netstat \
  prometheus-node-exporter-lua-nat_traffic \
  prometheus-node-exporter-lua-thermal \
  prometheus-node-exporter-lua-hwmon \
  prometheus-node-exporter-lua-uci_dhcp_host
Click to expand and view more

Alternatively, install packages through Admin PanelApplicationsPlug-ins.

PackageDescription
prometheus-node-exporter-luaCore exporter — CPU, memory, disk, network
prometheus-node-exporter-lua-openwrtOpenWRT-specific metrics
prometheus-node-exporter-lua-wifiWi-Fi interface statistics
prometheus-node-exporter-lua-wifi_stationsConnected Wi-Fi client metrics
prometheus-node-exporter-lua-netstatTCP/UDP connection statistics
prometheus-node-exporter-lua-nat_trafficNAT traffic counters
prometheus-node-exporter-lua-thermalThermal zone temperatures
prometheus-node-exporter-lua-hwmonHardware sensor readings
prometheus-node-exporter-lua-uci_dhcp_hostDHCP host information

Enable the Exporter

By default the exporter only listens on localhost. Expose it on the LAN interface:

BASH
uci set prometheus-node-exporter-lua.main.listen_interface='lan'
uci set prometheus-node-exporter-lua.main.listen_port='9100'
uci commit prometheus-node-exporter-lua
/etc/init.d/prometheus-node-exporter-lua enable
/etc/init.d/prometheus-node-exporter-lua restart
Click to expand and view more

Verify from another machine on the same network:

BASH
curl http://192.168.8.1:9100/metrics
Click to expand and view more

Add Prometheus Scrape Job

Add the following to your prometheus.yml, then restart Prometheus:

prometheus.yml
  - job_name: 'glinet'
    scrape_interval: 15s
    static_configs:
      - targets: ['192.168.8.1:9100']
        labels:
          router: glinet
Click to expand and view more
BASH
docker restart prometheus
Click to expand and view more

Use the pre-built GL.iNet / OpenWRT Dashboard to visualize the metrics in Grafana.

Logs via Syslog

Configure GL.iNet

Via SSH

Replace 192.168.8.101 with the IP of your Alloy instance:

BASH
uci set system.@system[0].log_ip='192.168.8.101'
uci set system.@system[0].log_port='514'
uci set system.@system[0].log_proto='udp'
uci set system.@system[0].conloglevel='7'
uci commit system
/etc/init.d/log restart
Click to expand and view more

The conloglevel controls verbosity: 7 = debug, 6 = info, 4 = warning, 3 = error.

Via LuCI

Tip: LuCI is not installed by default on GL.iNet routers. Enable it under Admin PanelSystemAdvanced Settings.

  1. Navigate to SystemSystemLogging
  2. Set External system log server to your Alloy instance IP
  3. Set port to 514, protocol to UDP, log level to Info
  4. Click Save & Apply

Configure Grafana Alloy

Create a new Alloy config file for GL.iNet syslog collection:

BASH
nano alloy/config/glinet-syslog.alloy
Click to expand and view more
glinet-syslog.alloy
/* GL.iNet Syslog (BSD/RFC3164) */
loki.relabel "glinet_syslog" {
  forward_to = []

  rule {
    source_labels = ["__syslog_message_hostname"]
    target_label  = "host"
  }

  rule {
    source_labels = ["__syslog_message_app_name"]
    target_label  = "service_name"
  }

  rule {
    source_labels = ["__syslog_message_severity"]
    target_label  = "detected_level"
  }
}

loki.source.syslog "glinet" {
  listener {
    address                = "0.0.0.0:514"
    protocol               = "udp"
    syslog_format          = "rfc3164"
    use_incoming_timestamp = false
    labels                 = {
      job = "glinet",
    }
  }

  relabel_rules = loki.relabel.glinet_syslog.rules
  forward_to    = [loki.write.default.receiver]
}
Click to expand and view more

Restart Alloy to load the new configuration:

BASH
docker restart alloy
Click to expand and view more

Verification

Metrics — Query in Grafana to confirm data is flowing:

PROMQL
node_cpu_seconds_total{router="glinet"}
Click to expand and view more

Logs — Query in Grafana’s Explore view:

LOGQL
{job="glinet"}
Click to expand and view more

Copyright Notice

Author: Sven van Ginkel

Link: https://svenvg.com/posts/monitoring-gl.inet-with-grafana/

License: CC BY-NC-SA 4.0

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Please attribute the source, use non-commercially, and maintain the same license.

Start searching

Enter keywords to search articles

↑↓
ESC
⌘K Shortcut