Skip to main content

Building a Prometheus Dashboard in Grafana

Hands-On Lab

 

Photo of Will Boyd

Will Boyd

DevOps Team Lead in Content

Length

00:45:00

Difficulty

Intermediate

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.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Building a Prometheus Dashboard in Grafana

Introduction

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.

Solution

  1. Access the Grafana server at http://<GRAFANA_SERVER_PUBLIC_IP>:3000.

  2. Log in with the username admin.

  3. The default admin password is the same as the server password.

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.

  3. For the dashboard name, enter "LimeDrop Web Server".

  4. Click Save.

  5. Click the Add panel button near the top right.

  6. Click Add Query.

  7. For the PromQL query, enter:

    up{instance="limedrop-web:9100"}
  8. Click the Visualization icon.

  9. Click the visualization type dropdown (which currently says Graph) and change it to Singlestat.

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

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

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

  13. Click the back button in the top left (next to LimeDrop Web Server). You should see your dashboard, and the Server Status panel should say Up.

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

Create a CPU Usage Graph Panel

  1. Click the Add panel button near the top right.

  2. Click 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.

  5. Change the panel title to "CPU Usage".

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

  7. 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.

  2. Click Add Query.

  3. For the PromQL query, enter:

    100 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100
  4. Click the General icon.

  5. Change the panel title to "Memory Usage".

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

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

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

Conclusion

Congratulations on successfully completing this hands-on lab!