Prometheus provides a server-level metrics exporter called node_exporter
that reports hardware & kernel-level metrics. However, I found the container deployment method in Docker to be too extreme, and there was no clear documentation for setting it up manually or any officially supported package on Fedora.
Other unofficial online resources didn’t mention working with SELinux or firewalld, so this guide outlines how to set up a basic node_exporter
daemon on a Fedora 41 server.
download and extraction
Fairly straightforward, find your appropriate version on the downloads page and download it:
1 | curl -JLO https://github.com/prometheus/node_exporter/releases/... |
and extract it:
1 | tar -xvf node_exporter-1.9.1.linux-amd64.tar.gz |
user creation and manual installation
Manual installation involves moving the executable to the /usr/local/bin/
directory, which is specifically for programs that normal users can run.
1 | sudo mv node_exporter-1.9.1.linux-amd64/node_exporter /usr/local/bin/ |
Create the node_exporter
user & group for the service account that runs the binary, and apply them to the binary. It does not need to run with any special privileges to gather metrics, and the login shell is disabled for security:
1 | sudo useradd -rs /sbin/nologin node_exporter |
systemd unit file
Create the systemd unit file at /etc/systemd/system/node_exporter.service
:
1 | [Unit] |
This is a very simple configuration that gets node_exporter
listening on all interfaces on the default port 9100
.
SELinux relabelling
Depending on where/how you downloaded it, the binary will likely have an incorrect SELinux label:
1 | [gadget@trinity ~]# ls -Z /usr/local/bin/ |
This means that attempting to start it will fail. This is the journalctl
log, and you can see SELinux kicking in with the AVC
line:
1 | ... |
Fixing this is easy since the binary is located in the correct directory. The restorecon
command with the recursive flag (-R
) will apply the parent folder’s label to its children, and /usr/local/bin
is already defined with a specific label:
1 | sudo restorecon -R -v /usr/local/bin/ |
In this case, SELinux is in targeted
mode rather than MLS
mode, so unconfined_u
is still allowed to run:
1 | [gadget@trinity ~]# ls -Z /usr/local/bin/ |
open firewall port
If firewalld
is enabled and running (the default), you will need to open its port to query the metrics from another host.
You can check the active firewalld
zone with:
1 | [gadget@trinity ~]$ firewall-cmd --get-active-zones |
Then, add the port as an exception to the zone:
1 | sudo firewall-cmd --zone=public --add-port=9100/tcp --permanent |
start node_exporter
and test
Enable and start node_exporter
in one line:
1 | sudo systemctl enable --now node_exporter |
and from another host, query the endpoint:
1 | curl trinity.local:9100/metrics |
You will be greeted by a wall of metrics:
1 | # HELP go_gc_duration_seconds A summary of the wall-time pause (stop-the-world) duration in garbage collection cycles. |
resources
- Prometheus Node Exporter home page:
https://prometheus.io/docs/guides/node-exporter/