Learning how to monitor my Openwrt router using Prometheus and Grafana step by step

Hello everyone, how are you?

I want to learn how to monitor my router using Grafana dashboards and I would like some help from you.

First of all, I must warn you that I know absolutely nothing about this - I have seen some very functional and cool dashboards on the internet, so I decided to try to learn how to do this.

I would like to know if you have any tutorial for dummies, where you teach how to install the Prometheus plugins on the router (this is easy), where you teach how to configure the database and create the dashboard, but as I said, it needs to be step by step, for a dummie.

I can host this database on my router if it is possible to install it, because I have plenty of space on the disk and I believe that, with 4 GB of RAM, I could run Openwrt and the database without any major problems... I would like to host the dashboard on the Grafana website, with that free account that is possible to create.

Initially, it would be more for the purpose of studying, gaining knowledge and, in the future, offering this monitoring service to my clients.

I apologize for the long text, but that's it. Does anyone have a starting point for studying this subject?

Cheers

1 Like

This might help you to get started https://giuliomagnifico.blog/post/2022-06-02-my-network-home-setup/

Not tried it myself but as far as I know you need

  • Openwrt package prometheus-node-exporter-ucode for basic metrics or
  • OpenWrt package collectd-mod(many options) + package collectd-mod-network + collectd exporter on the server for advanced metrics

Also nice to have are traffic metrics https://github.com/mstojek/nlbw2collectd

Next to the above you need Prometheus on your server to store metrics

4 Likes

What router?

Do you have a Pi?

You can play with the firmware without having to worry about bricking one.
If you have one laying around, I'd play with that to learn.

As for tutorials for visual learners: I'd look for the most recent video from a channel with a lot of followers and a videos with lots of hits.
Try to avoid anything over 18 months.

For money? Then you should be able to invest your business time and money into doing the research yourself. Use a search engine. Use a LLM.

Maybe you are to literally? Maybe it's only clients in the sense of computers....

1 Like

Haha, thanks for the reminder. :joy:

Well then the answer is: check the wiki.
Though you will quickly find out it's outdated.

Collectd seems to be a dying project. The alternatives I have found so far are all very memory and disk space hungry.

But since you have 4GB RAM (is that a BPI-R4?) and plenty of space, that shouldn't be an issue.

For setting up the services you can either run them directly on the host, which means you need openwrt packages for those which don't exist, so you need to create them and or compile locally or install manually.
The other option is using docker or podman to run them as containers. Those come pre-built, but then you have the hazzle of setting up containers, networking, ports, and such.

Hello everyone, I will try to answer you all...

Sorry for the delay.

I'm using an x86 router based on an old PC that was sitting around here at home.

I'm currently running Proxmox on it, and I have Openwrt installed and it's working perfectly...

I have other VMs installed and configured on this machine, so memory and disk space aren't a problem...

As I said, I know absolutely nothing about Grafana. Installing the Prometheus plugins on the router is incredibly simple - I've already done it and can see the metrics being displayed.

What I wanted to learn how to do was install Prometheus on a Linux (Debian fan <3), learn how to configure the database and also create dashboards...

Of course, initially this would be a lab, based on my information, for learning... and why not, deliver this monitoring to my clients who use Openwrt in companies, residential condominiums (internet distribution in common areas), among others.

I have routers and access points with uptime of more than 200 days running Openwrt "like a rock"...

Thank you for this little guide!

I will study it carefully, thank you for sharing this little path.

Cheers!

1 Like

So I recently went through doing this. On my MT-6000 with openwrt I use collectd to collect and forward metrics, and remote syslog to forward logs.

On my Pi 5 I run docker, with a docker-compose file containing:

  • Prometheus (database for statistics)
  • Grafana (visualisation)
  • Grafana Loki (database for logs)
  • Grafana Alloy (receives syslog, pi journald logs and docker container logs; sends it to loki) (Note: this runs outside docker, to be able to collect host logs. Just a normal systemd service.)
  • Prometheus collectd exporter (receives collectd metrics, sends it to prometheus)

This took a bit to setup, especially Grafana Alloy needs quite a bit of configuration. If you have specific questions I may be able to help.

I might get around to cleaning up the config files etc for public consumption and could put them up somewhere, but I won't make a promise I can't guarantee that I can keep.

1 Like

@_bernd guess I was right, sorry. :sweat_smile:

There is one? Oh, I was going the route the other person went using collectd. But I found out the other day that collectd isn't really maintained anymore. There was a version 6 last year, but it is only a release candidate and hasn't had an update or commits since.

If you use docker containers and especially docker compose, those things make it really simple.
Or even use a container handling UI like portainer, so you don't have to deal with the dockerfile and such.

My setup currently is using podman (which adds more effort to setup and doesn't come with compose capabilites out of the box). Then collectd on the openwrt host and Victoriametrics and Grafana inside containers.
Doesn't work yet, because all the write plugins for collectd that would be compatible with Victoria, are not available on openwrt. So I would have to compile that myself.
Maybe I will try the Prometheus exporter.

Would be cool to have something that just works out of the box.

1 Like

I found (for desktop/server Linux at least) that collectd support more metrics than the prometheus node exporter. In particular it seems the node exporter doesn't support hardware sensors (apart from SMART data). No lm-sensors support to get CPU temp or voltages. This works with collectd. Maybe I missed something.

For openwrt there is a Lua based node exporter, I don't know if it supports hardware sensors or not.

Thanks, that was also my understanding. And I haven't even checked yet the file size and memory usage of the Prometheus exporter. These go executables tend to be rather big.

I was trying to build something in rust yesterday, but they like to compile statically, which isn't that fitting for openwrt.

Nah, no need to. I think it's fair enough. There a lot of companies around openwrt and only a few devs are transparent about that fact. :man_shrugging:

As a rust (and C++) developer myself, I haven't looked into running rust on openwrt. But you can link dynamically to libc at least. And you can run rust on microcontrollers. Check out https://github.com/johnthagen/min-sized-rust for some tips.

Some of those tips are only going to help if you are the developer of the software, but some are just about compilation flags.

Still, many rust programs should be fine for more spacious devices (such as the GL.iNet Flint 2 that I have, with 8 GB EMMC).

Oh and Go is even worse when it comes to linking things statically. They don't even want to link libc at all (doing their own syscalls directly). Plus, unlike Rust, they use garbage collected memory. Rust, like C and C++, can be rather frugal with RAM usage.

2 Likes

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.