📊 Monitoring Linux Servers with Node Exporter on Amazon Lightsail
In this guide, we'll walk through how to configure Node Exporter on an Amazon Lightsail instance to collect Linux system metrics like CPU, memory, disk, and network usage. These metrics can then be visualized in Grafana via Prometheus.
🔧 Why Node Exporter?
Node Exporter is a Prometheus exporter that exposes key system metrics. It’s lightweight, easy to deploy, and perfect for gaining insights into the health and performance of your server.
🧭 Step-by-Step Setup
✅ Step 1: SSH into Your Lightsail Server
ssh ubuntu@your-lightsail-ip
Replace your-lightsail-ip
with your actual instance's public IP.
✅ Step 2: Download and Install Node Exporter
export NODE_EXPORTER_VERSION=1.9.1
wget https://github.com/prometheus/node_exporter/releases/download/v${NODE_EXPORTER_VERSION}/node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz
tar xvfz node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64.tar.gz
sudo mv node_exporter-${NODE_EXPORTER_VERSION}.linux-amd64/node_exporter /usr/local/bin/
This installs the latest Node Exporter binary into a location in your PATH.
✅ Step 3: Create a systemd Service
To keep Node Exporter running in the background and start it on boot, we create a systemd service:
sudo tee /etc/systemd/system/node_exporter.service > /dev/null <<EOF
[Unit]
Description=Node Exporter
After=network.target
[Service]
User=nobody
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=default.target
EOF
Enable and start the service:
sudo systemctl daemon-reexec
sudo systemctl enable node_exporter
sudo systemctl start node_exporter
Check status:
sudo systemctl status node_exporter
Check logs if needed:
journalctl -u node_exporter -f
✅ Step 4: Open Port 9100 in Lightsail Firewall
By default, Lightsail blocks custom ports. Here’s how to allow Prometheus to reach port 9100
:
-
Go to the Amazon Lightsail Console
-
Click your Symfony instance
-
Go to the Networking tab
-
Under Firewall, click Add another
- Application: Custom
- Port range:
9100
- Protocol: TCP
- Source type: Anywhere (or restrict to Prometheus IP)
-
Save the rule.
Test it:
curl http://your-lightsail-ip:9100/metrics
✅ Step 5: Configure Prometheus to Scrape Node Exporter
On your Prometheus server (e.g., Docker):
In your prometheus.yml
:
- job_name: 'lightsail-node'
static_configs:
- targets: ['your-lightsail-ip:9100']
Then reload Prometheus:
docker exec -it prometheus kill -HUP 1
Or if lifecycle is enabled:
curl -X POST http://localhost:9090/-/reload
✅ Step 6: Add Dashboard to Grafana
- Go to Grafana → Dashboards → Import
- Enter dashboard ID:
1860
(Node Exporter Full) - Select Prometheus as your data source
- Click Import
🧠 Wrap-up
You now have a powerful, production-ready system metrics dashboard for your Amazon Lightsail server running Symfony.
This same setup can be extended to:
- Raspberry Pi
- On-prem servers
- Other cloud instances
Happy monitoring! 🎯
---