Monitoring services is a big part of Cloud Infrastructure Management. Here we will go through one way to install Prometheus on Ubuntu and make pretty dashboards with Grafana on a separate machine.
Go grab this download and extract to start:
wget https://github.com/prometheus/prometheus/releases/download/v2.30.3/prometheus-2.30.3.linux-amd64.tar.gz
tar -xvzf prometheus-2.11.1.linux-amd64.tar.gz
cd prometheus/
./prometheus
Open a web browser and head over to the http://{IP}:9090/graph
So far, So Good
You can see the raw metrics by going to http://{IP}:9090/metrics
You can check what is up by going to /targets
Let's run it as a service, create this file:
/etc/systemd/system/prometheus.service
And give it this basic text settings:
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target
[Service]
User=root
Restart=on-failure
#Change this line if you download the
#Prometheus on different path user
ExecStart=~/prometheus/prometheus --storage.tsdb.path=/var/lib/prometheus/data/ --web.external-url=http://myurl.com:9090
[Install]
WantedBy=multi-user.target
Make sure to reload it and start it up:
sudo systemctl daemon-reload
sudo systemctl start prometheus
There are Exporters you can add to Prometheus to increase the utility. Node Exporter is one.
wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
tar -xvzf node_exporter-0.18.1.linux-amd64.tar.gz
mv node_exporter-0.18.1.linux-amd64 node_exporter
cd node_exporter
./node_exporter
You can open the service in a browser at http://{IP}:9100
You can add the node exporter to Prometheus in /etc/prometheus/prometheus.yml
Let's make it into a service. Create a file:
sudo vi /etc/systemd/system/node_exporter.service
[Unit]
Description=Node Exporter
After=network.target
[Service]
User={user}
Group={user}
Type=simple
ExecStart=/usr/local/bin/node_exporter
[Install]
WantedBy=multi-user.target
Let's go ahead and get this going:
sudo systemctl daemon-reload
sudo systemctl start node_exporter
sudo systemctl status node_exporter
You can see the two services on /targets
If all is running well, enable this service to start at boot.
sudo systemctl enable node_exporter
That's enough for today. I will continue this in a second part for Grafana.
Top comments (0)