Setting Up Prometheus and Adding Endpoints

1 hour
  • 4 Learning Objectives

About this Hands-on Lab

In this hands-on lab, we get our monitoring solution up and running by installing Prometheus, Alertmanager, and Grafana, as well as ensuring metrics from all three services are being fed into Prometheus. This gives us a full monitoring platform so we can start performing both infrastructure and application monitoring and everything in between. As we install Prometheus and Alertmanager, we’ll also configure our environment so we can easily and effectively change our configurations without any added work.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Set up Prometheus
  1. On the monitoring server, create a user for Prometheus.
  2. Create the needed directories: /etc/prometheus and /var/lib/prometheus.
  3. Set the ownership of the /var/lib/prometheus directory.
  4. Download Prometheus (here’s the link).
  5. Extract the files.
  6. Move the configuration file to /etc/prometheus and set the owner to the prometheus user.
  7. Move the binaries and set the owner.
  8. Create the service file.
  9. Start Prometheus and make sure it automatically starts on boot.
Set up Alertmanager
  1. On the monitoring server, create the alertmanager system user.
  2. Create the needed directory: /etc/alertmanager.
  3. Download Alertmanager (here’s the link).
  4. Extract the files.
  5. Move the binaries.
  6. Set the ownership of the binaries.
  7. Move the configuration file into the /etc/alertmanager directory.
  8. Set the ownership of the /etc/alertmanager directory.
  9. Create the alertmanager.service file for systemd.
  10. Stop Prometheus, and then update the Prometheus configuration file to use Alertmanager.
  11. Reload systemd, and then start the prometheus and alertmanager services.
  12. Make sure alertmanager starts on boot.
Set up Grafana
  1. On the grafana server, install the prerequisite libfontconfig package.
  2. Download and install Grafana using the .deb package provided on the Grafana download page.
  3. Start Grafana.
  4. Ensure Grafana starts at boot.
  5. Using the Grafana IP address listed on the lab page, access Grafana’s web UI by navigating to <GRAFANA_IP_ADDRESS>:3000 in a new browser tab.
  6. Log in with the username admin and the password admin. Reset the password when prompted.
  7. Click Add data source on the home page.
  8. Select Prometheus.
  9. In the HTTP section, set the URL to http://<MONITORING_IP_ADDRESS>:9090 (using the public IP of the monitoring server provided on the lab page).
  10. Click Save & Test.
Add Alertmanager and Grafana Endpoints to Prometheus
  1. On the monitoring server, open the Prometheus configuration file.
  2. Add the Alertmanager endpoint.
  3. Add the Grafana endpoint.
  4. Restart Prometheus.
  5. Using the public IP address of the monitoring server, navigate to the Prometheus web UI in a new browser tab:http://<MONITORING_IP_ADDRESS>:9090
  6. Ensure all three endpoints are listed on the Targets page.

Additional Resources

The time has come to set up a monitoring solution for your infrastructure. After much debate, you've settled on using Prometheus for monitoring, along with Alertmanager for alerting, Grafana for visualization, and the aggregation of metrics and data across any data-collecting tools beyond Prometheus.

When setting up Prometheus, you want to host Prometheus and Alertmanager on a single monitoring server, with Grafana located on a second, separate server. You also want to ensure you can use the systemctl command with all services, so the creation of systemd service files for both Prometheus and Alertmanager is necessary (see the lab guide for ones you can copy and paste).

Additionally, you want to add Prometheus as a data source for Grafana.

Once all three tools are set up, add Alertmanager and Grafana as endpoints for Prometheus; ensure you can view these endpoints from the Targets page on the Prometheus web UI.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?