Building a Prometheus Dashboard in Grafana

45 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Prometheus and Grafana create a powerful combination. Grafana allows you to build useful visualizations on top of your Prometheus metric data. In this lab, you will have the opportunity to build a Grafana dashboard to visualize Prometheus metrics. This will give you some hands-on experience with building useful Grafana dashboards on top of Prometheus.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create the Dashboard and Add a Web Server Status Panel
  1. Click the Create button on the left, and then select Dashboard.

  2. Click the Save Dashboard button near the top right. For the dashboard name, enter "LimeDrop Web Server", and then save.

  3. Click the Add Panel button near the top right, and then Add Query.

  4. For the PromQL query, enter:

    up{instance="limedrop-web:9100"}
  5. Click the Visualization icon. Click the visualization type dropdown that currently says Graph and change it to Singlestat.

  6. Under Value Mappings, enter two value to text mappings:

    • 1 -> Up
    • 0 -> Down
  7. Click the General icon.

  8. Change the panel title to "Server Status".

  9. Click the back button in the top left. You should see your dashboard, and the Server Status panel should say Up.

  10. Click the Save Dashboard button near the top right, and then Save to save your changes.

Create a CPU Usage Graph Panel
  1. Navigate to the LimeDrop Web Server dashboard.

  2. Click the Add Panel button near the top right, and then Add Query.

  3. For the PromQL query, enter:

    sum(rate(node_cpu_seconds_total{instance='limedrop-web:9100',mode!='idle'}[5m])) * 100
  4. Click the General icon, and change the panel title to "CPU Usage".

  5. Click the back button in the top left. You should see your dashboard, and there should be a graph showing CPU utilization.

  6. Click the Save Dashboard button near the top right, and then Save to save your changes.

Create a Memory Usage Graph Panel
  1. Click the Add Panel button near the top right, and then Add Query.

  2. For the PromQL query, enter:

    100 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100
  3. Click the General icon, and change the panel title to "Memory Usage".

  4. Click the back button in the top left. You should see your dashboard, and there should be a graph showing memory utilization.

  5. Rearrange your panels by dragging and dropping them if desired.

  6. Click the Save Dashboard button near the top right, and then Save to save your changes.

Additional Resources

Your company, LimeDrop, is using Prometheus and Grafana to monitor a variety of applications and infrastructure components. One of the servers being monitored is a Linux web server. The metrics for this server are in Prometheus, but there is currently no way for the administrators to visualize the data.

Your task is to build a dashboard in Grafana to display some basic information about the web server.

Build a dashboard with the title LimeDrop Web Server, and include the following:

  • A panel displaying the current status of the web server as "Up" or "Down". Use the up{instance="limedrop-web:9100"} metric.
  • A panel displaying a graph of CPU usage over time. Example query:
    sum(rate(node_cpu_seconds_total{instance='limedrop-web:9100',mode!='idle'}[5m])) * 100
  • A panel displaying a graph of Memory usage over time. Example query:
    100 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100

You can access the Grafana server at http://<GRAFANA_SERVER_PUBLIC_IP>:3000. Log in with the username admin. The default admin password is the same as the server password.

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?