This article is part of the Prometheus Monitoring Series. Other articles in this series:
After installing the relevant monitoring exporter software on each machine you want monitored, it is time to bring all that metrics together. This will enable you to see all machines’ status in one central location. Today we have a look at installing the monitoring dashboard for Prometheus, so let’s dive right in.
What Is Prometheus?
Let’s just quickly recap on why we are using our chosen software solution. Prometheus is an open-source monitoring and alerting tool that collects metrics from various systems, stores them in a time-series database, and helps you visualize the data using dashboards or charts. It’s particularly popular for monitoring servers, applications, and cloud-based services.
At its core, Prometheus works by pulling metrics from various sources, called exporters, which provide system-specific data.
Node Exporter vs. Prometheus Monitoring Service
Prometheus typically works with exporters to gather information. The Node Exporter is a small program installed on each machine that collects system-level data like CPU usage, memory consumption, disk space, and network traffic. It’s like a “sensor” for your machine.
The Prometheus Monitoring Service, on the other hand, is the “central brain.” It queries all the Node Exporters, stores their data, and processes it for analysis or alerts. While Node Exporter handles data collection, Prometheus handles storage, visualization, and analysis.
Installing Prometheus Monitoring Service
Prerequisites
- Ensure the Node Exporter is installed and running on the machines you want to monitor.
- Have administrative access to your system.
Installation on Windows
- Download Prometheus
- Visit the official Prometheus website.
- Download the latest Windows binary.
- Extract the Files
- Extract the downloaded ZIP file to a folder of your choice, e.g.,
C:\Prometheus
.
- Extract the downloaded ZIP file to a folder of your choice, e.g.,
- Edit the Configuration File
- Inside the extracted folder, locate
prometheus.yml
. - Open it with a text editor like Notepad.
- Add your Node Exporter endpoints under the
scrape_configs
section. Example:scrape_configs:
- job_name: "node_exporter"
static_configs:
- targets: ["localhost:9100", "192.168.1.10:9100"]
- Inside the extracted folder, locate
- Run Prometheus
- Open Command Prompt, navigate to the Prometheus folder, and run:
prometheus.exe --config.file=prometheus.yml
- Prometheus will start and be accessible in your browser at
http://localhost:9090
.
- Open Command Prompt, navigate to the Prometheus folder, and run:
Installation on Linux
- Download Prometheus
- Use
wget
to download the latest Prometheus binary:wget https://github.com/prometheus/prometheus/releases/download/vX.X.X/prometheus-X.X.X.linux-amd64.tar.gz
(ReplaceX.X.X
with the latest version number.)
- Use
- Extract the Files
- Extract the archive:
tar -xvf prometheus-X.X.X.linux-amd64.tar.gz
- Extract the archive:
- Edit the Configuration File
- Open
prometheus/prometheus.yml
with a text editor:sudo nano prometheus.yml
- Add your Node Exporter endpoints under the
scrape_configs
section, similar to the Windows example.
- Open
- Set Up a Systemd Service
- Create a service file:
sudo nano /etc/systemd/system/prometheus.service
- Add the following configuration:
[Unit]
Description=Prometheus
After=network.target
[Service]
User=prometheus
ExecStart=/usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yml
[Install]
WantedBy=multi-user.target
- Create a service file:
- Start and Enable Prometheus
- Reload systemd and start Prometheus
sudo systemctl daemon-reload
sudo systemctl start prometheus
sudo systemctl enable prometheus
- Reload systemd and start Prometheus
- Access Prometheus
- Open your browser and visit
http://<your_server_ip>:9090
.
- Open your browser and visit
Considerations When Using Prometheus
- Scaling: Prometheus is designed for small to medium-scale systems. For larger environments, you may need to explore federation or external storage integrations.
- Data Retention: By default, Prometheus retains data for 15 days. Adjust this in the configuration if needed, but be aware it may increase storage requirements.
- Alerting: To receive alerts, set up Alertmanager, an accompanying tool for Prometheus.
- Security: Prometheus does not include native authentication. Secure access to the dashboard using firewalls or reverse proxies with authentication.
Conclusion
Prometheus is a robust monitoring tool that simplifies tracking the performance of your systems. While the Node Exporter handles data collection, the Prometheus Monitoring Service centralizes and processes this data for analysis. By following this guide, you can install Prometheus on Windows or Linux and start monitoring your systems effectively.
Keep in mind factors like scalability, storage, and security when setting up your monitoring system. With Prometheus, you’ll be better equipped to maintain the health and performance of your machines, no matter their scale.
Now that you have Prometheus up and running, take some time to explore its powerful querying and visualization capabilities. Happy monitoring!