Monitoring DigitalOcean Droplets with Prometheus
- Create a Private Network
- Setup Prometheus
- Install Node Exporter
Create a Private Network
Segmenting traffic gives you more flexibility and security. In most deployments users do not want their monitoring traffic flowing over public facing interfaces.
Full docs on how to setup private networking below. You will need to do this on all the droplets you want to monitor.
https://www.digitalocean.com/docs/networking/private-networking/how-to/enable/

Setup Prometheus
Create a new droplet that will host the Prometheus instance.
You can also get prometheus running from the DigatalOcean Marketplace
Install Node Exporter
Node Exporter gathers OS level metrics and presents them over HTTP for Prometheus to scrape.
Download NodeExporter
cd /tmp
wget https://github.com/prometheus/node_exporter/releases/download/v1.0.1/node_exporter-1.0.1.linux-amd64.tar.gz
#check MD5
tar -xf node_exporter-1.0.1.linux-amd64.tar.gz
cd node_exporter-1.0.1.linux-amd64/
cp node_exporter /usr/local/bin/
useradd -r node_exporter
nano /etc/systemd/system/node_exporter.service
systemctl daemon-reload
service node_exporter status
service node_exporter start
Service File
/etc/systemd/system/node_exporter.service
[Unit]
Description=Prometheus Node Exporter
After=network.target
[Service]
Type=simple
User=node_exporter
Group=node_exporter
ExecStart=/usr/local/bin/node_exporter \
--web.listen-address=private_IP_here:9100
SyslogIdentifier=node_exporter
Restart=always
PrivateTmp=yes
ProtectHome=yes
NoNewPrivileges=yes
ProtectSystem=strict
ProtectControlGroups=true
ProtectKernelModules=true
ProtectKernelTunables=yes
[Install]
WantedBy=multi-user.target
If you have ufw enabled you'll have to allow TCP port 9100
ufw status numbered
# allow port 9100 TCP
ufw allow proto tcp from any to any port 9100
Update the Prometheus Config
nano /etc/prometheus/prometheus.yml
- job_name: 'node'
static_configs:
- targets: ['IP01:9100','IP02:9100','IP03:9100']
service prometheus reload
Larger deployments should look into Service Discovery instead of a static list of nodes in the prometheus.yml
https://github.com/prometheus/prometheus/tree/master/discovery
Get $100 in cloud credits from DigitalOcean using my link: https://m.do.co/t/909d52b6253a