Install Prometheus Service and Data Source
Prometheus is already available on the default Ubuntu 20.04 repositories. So we can just install it and it will be set up as a service already.
sudo apt install prometheus
It has installed two services named
prometheus-node-exporter. We can check them using
sudo service prometheus status
sudo service prometheus-node-exporter status
ctrl-c to exit each of the above status commands.
We can test the Prometheus metrics endpoint is running locally by using the command
If your server is on the public internet, it may be accessible via the address http://[your domain or ip]:9100/.
If you are not using a dedicated firewall, then you can block it for external users by using these
iptables rules below.
iptables -A INPUT -p tcp -s localhost --dport 9090 -j ACCEPT iptables -A INPUT -p tcp --dport 9090 -j DROP iptables -L
After installing Prometheus using
dnf etc, it is also likely to have,
- installed a local Prometheus Node Exporter,
- created and started 2 services for Prometheus and Prometheus Node Exporter,
- created a specific user called
prometheusthat both services are running under.
You can check the
prometheus user using the command
You can check which processes it is running by using the command
ps -u prometheus
You can see which ports each process is listening on by using the command
ss -ntlp | grep prometheus
The Prometheus Node Exporter also creates a
metrics http endpoint on port 9100. You can check it locally using
If your server is on the public internet, and you haven't configured a dedicated firewall, it may be accessible via the address http://[your domain or ip]:9100/
You can also restrict access to port 9100 using
iptables if you need.
iptables -A INPUT -p tcp -s localhost --dport 9100 -j ACCEPT iptables -A INPUT -p tcp --dport 9100 -j DROP iptables -L
iptables settings will be lost in case of system reboot. You will need to reapply them manually,
sudo apt install iptables-persistent
This will save your settings into two files called,
Any changes you make to the iptables configuration won't be auto saved to these persistent files, so if you want to update these files with any changes, then use the commands,
iptables-save > /etc/iptables/rules.v4
iptables-save > /etc/iptables/rules.v6
If you want to try a more detailed course on Prometheus, then you can visit my Prometheus tutorials.
Grafana 9 and Ubuntu 22.04 Notes
Daemons using outdated libraries
Since Ubuntu 22.04, installing new packages may give you a full screen prompt to restart other dependent services. Press Tab to highlight the
OK option, and press Enter.
Prometheus Data Source.
In Grafana 9, when exploring the new Prometheus data source, the default view is the new Builder UI. My video shows the Code UI, where it shows the
Metrics browser option.
You can view the Code UI by pressing the option at the right of the screen.