Skip to main content

Building a Grafana Instance to Work with Prometheus Data

Hands-On Lab

 

Photo of Will Boyd

Will Boyd

DevOps Team Lead in Content

Length

00:45:00

Difficulty

Intermediate

Prometheus is a powerful tool for reliably collecting and serving metric data, but its built-in visualization capabilities are limited. Luckily, Prometheus can easily integrate with more robust visualization tools such as Grafana, allowing you to build robust and useful dashboards to get the most out of your data. In this lab, you will have the opportunity to build a Grafana server and configure it to access Prometheus metric data. After completing this lab, you will know how to install Grafana and integrate it with 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 Grafana Instance to Work with Prometheus Data

Introduction

Prometheus is a powerful tool for reliably collecting and serving metric data, but its built-in visualization capabilities are limited. Luckily, Prometheus can easily integrate with more robust visualization tools such as Grafana, allowing you to build robust and useful dashboards to get the most out of your data. In this lab, you will have the opportunity to build a Grafana server and configure it to access Prometheus metric data. After completing this lab, you will know how to install Grafana and integrate it with Prometheus.

Solution

Log in to the Grafana server using the credentials provided:

ssh cloud_user@<GRAFANA_SERVER_PUBLIC_IP>

Install and Run Grafana

  1. Log in to the Grafana server.

  2. Install some required packages:

    sudo apt-get install -y apt-transport-https software-properties-common wget
  3. Add the GPG key for the Grafana OSS repository:

    wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
  4. Add the repository:

    sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
  5. Install the Grafana package:

    sudo apt-get update
    sudo apt-get install grafana=6.6.2
  6. Enable and start the grafana-server service:

    sudo systemctl enable grafana-server
    sudo systemctl start grafana-server
  7. Make sure the service is in the active (running) state:

    sudo systemctl status grafana-server
  8. Press Ctrl+C to stop the process.

  9. Verify Grafana is working by accessing it in a web browser at http://<GRAFANA_SERVER_PUBLIC_IP>:3000.

Configure a Prometheus Data Source on the Grafana Server

  1. Log in to Grafana with the username admin and password admin.

  2. Reset the password when prompted.

  3. Click Add data source.

  4. Select Prometheus.

  5. For the URL, enter http://10.0.1.101:9090. Note that 10.0.1.101 is the private IP address of the Prometheus server.

  6. Click Save & Test. You should see a banner that says, Data source is working.

  7. Click the Explore icon on the left.

  8. In the PromQL Query input, enter a simple query, such as up.

  9. Click Run Query. Some data should then appear. If so, congratulations! This data comes from the Prometheus server.

Conclusion

Congratulations on successfully completing this hands-on lab!