Prometheus Monitoring: A Simple Guide To Monitoring Your Machines

Prometheus

So you have a fantastic NAS set up, or even a NUC PC on your network. Maybe you are running Home Assistant on your Raspberry Pi of have Plex running on an old machine. Of course having a SmartOS machine to complement your home lab is amazing, but in all of those cases: How do we monitor them and ensure they are up and running? The easiest and best way is to use software called Prometheus Monitoring. We can also use a visual Dashboard tool called Grafana. For today, lets look at setting up the Prometheus monitoring software on the nodes we want to monitor.


What Is Prometheus?

Prometheus is an open-source monitoring and alerting toolkit designed for system and application monitoring. Created by engineers at SoundCloud in 2012, it is now a widely-used solution maintained by the Cloud Native Computing Foundation (CNCF).

At its core, Prometheus collects data about your system (metrics) and stores it in a time-series database. This allows you to track system performance over time, spot trends, and detect problems early. It’s especially popular for monitoring dynamic cloud-native environments, but it works just as well for personal or small-scale setups.


How Prometheus Works

Prometheus works by periodically querying data (or scraping) from endpoints known as exporters. These exporters expose metrics from your system or application, which Prometheus collects and stores. The data is then made accessible through a powerful query language called PromQL.

Here’s a simplified process:

  1. Scraping: Prometheus collects metrics from targets (like your system or application) at regular intervals.
  2. Storage: It stores the metrics in a time-series database.
  3. Querying: You can query the stored metrics using PromQL to generate reports or visualize them in dashboards.
  4. Alerting: Prometheus can trigger alerts when certain conditions are met (e.g., if your CPU usage is too high).

Examples of Metrics Prometheus Monitors

Prometheus can monitor a variety of metrics, such as:

  • System Performance Metrics: CPU usage, memory utilization, disk I/O, and network traffic.
  • Application Metrics: Response time, error rates, and request throughput for web applications.
  • Custom Metrics: Metrics specific to your application or service, such as the number of active users or database queries per second.

For instance, if you’re running a website, Prometheus can monitor your server’s uptime, track the number of HTTP requests it handles, and detect if there are any unusual delays in responses.


Installing Prometheus (Node Exporter)

For Windows

Download the Windows Exporter

  • Visit the Windows Exporter GitHub Releases Page.
  • Get the latest release, and select the appropriate install file under the assetssection.
  • Download the latest .msi installer file. (You might need to install as administrator to get the service to start afterwards)

Install the Exporter

Install Prometheus
Install Prometheus
  • Run the .msi installer.
  • Follow the installation wizard and choose the components you want to monitor. Common options include:
    • CPU
    • Memory
    • Disk
    • Network
  • By default, the exporter runs as a Windows service after installation.

Verify the Installation

  • Open a web browser and navigate to:
    http://localhost:9182/metrics
  • You should see a list of metrics exposed by the Windows Exporter.

For Linux

  1. Download Prometheus:
    • Go to the Prometheus Node Exporter Downloads page (https://prometheus.io/download#node_exporter) and get the download for your OS and Architecture
    • Run the following command to download Prometheus:
      wget https://github.com/prometheus/node_exporter/releases/download/v<VERSION>/node_exporter-<VERSION>.<OS>-<ARCH>.tar.gz
    • Remember to replace the <VERSION> with the latest, <OS> and <ARCH> with your respective values.
  2. Extract the Files:
    • Extract the downloaded tar file:
      tar xvfz node_exporter-*.*-amd64.tar.gz
  3. Open the folder
    • Navigate to the folder:
      cd node_exporter-*.*-amd64
  4. Run Prometheus:
    • Start Prometheus by running:
      ./node_exporter
  5. Access the Interface:
    • Open your browser and go to http://<your-server-ip>:9100.

Considerations When Using Prometheus

  1. Scalability:
    • Prometheus is ideal for small to medium setups. For larger environments, you might need additional tools like Thanos for scaling.
  2. Retention Period:
    • By default, Prometheus stores metrics for 15 days. If you need long-term storage, you’ll need to configure remote storage.
  3. Exporter Selection:
    • Prometheus requires exporters for gathering metrics. Choose exporters suited to your system, such as node_exporter for system metrics or mysql_exporter for MySQL databases.
  4. Security:
    • Prometheus doesn’t include built-in authentication or encryption. Use reverse proxies or secure networks to protect your setup.
  5. Visualization:
    • While Prometheus has a basic UI, pairing it with a tool like Grafana provides more advanced visualization options.

Conclusion

Prometheus is a powerful and flexible tool that makes monitoring systems and applications straightforward. By collecting and storing time-series data, it helps you gain insights into your system’s performance and stability. Whether you’re monitoring CPU usage, tracking application response times, or setting up custom alerts, Prometheus is a great solution for keeping your infrastructure healthy.

With straightforward installation steps for both Windows and Linux, and considerations for best practices, you can start monitoring your system today and enjoy the peace of mind that comes with a well-maintained setup. Stay tuned to find out how we take this exported metrics and get a central location to browse all the metrics of all monitored machines.