How To Integrate and Visualize Prometheus Metrics In Grafana

Grafana is one of the best open source visualization tools. It can be easily integrated with Prometheus for visualizing all the target metrics.

Visualize Prometheus Metrics In Grafana

In this guide, we will walk you through the following.

  1. Install and configure Grafana
  2. Add Prometheus data source to Grafana
  3. Creating dashboards from Prometheus metrics.
  4. Importing shared Grafana dashboards

Install and Configure Grafana

Centos/Redhat

1. Get the latest rpm download link from the official downloads page and download it.

2. Install the rpm.

Ubuntu/debian

1. Download the debian package.

2. Install the packages

Configure Grafana

1. Start and enable the grafana server.

2. Access grafana UI on port 3000.

The default username and password is admin. You will be prompted to change the default passsord.

Add Prometheus Source To Grafana

Note: Make sure Prometheus endpoint is accessible from Grafana server.

1. Click the “add source” option from the Grafana homepage.

prometheus grafana add source

2. Add the source name, Prometheus endpoint details and save it.

prometheus grafana source

Create Dashboards From Prometheus Source

1. Select the create dashboard option as shown below.

prometheus grafana create dashboard

2. Select the graph type. You can select the type based on the type of visualization and dashboard you need.

READ  Setting up a Multi-Broker Kafka Cluster - Beginners Guide

prometheus graph selection

3. Select the edit option from the panel top.

grafana edit panel

4. Select the Prometheus data source and enter the Prometheus expression that has to be graphed under the metrics tab. You can preview the graph using the preview button. Under the general tab, you can assign a name for the dashboard. Save the dashboard after preview.

In the following example, we have given the expression for calculating CPU seconds every minute.

prometheus dashboard source and preview

You can find all the saved dashboards under the home option.

grafana saved dashbaords

grafana dashbaords

Also, you can organize your dashboards under different folders based on your needs.

grafana create folders

Importing Predefined Grafana Dashboard Templates

You can import predefined templates to your Grafana server.

You can find all the shared community dashboards from Grafana Shared Templates

For demo purpose, we will use this template. https://grafana.com/dashboards/5990.

You can import a shared dashboard using the key or the JSON file as shown below.

grafana shared dashboard

1. Select the import option as shown below.

grafana import

2. Following are the supported import options. You can add the dashboard ID you get from grafana website, upload the json or paste the json in the text box.

3. Add a template name, Prometheus source, destination dashboard folder and click import.

prometheus grafana import options

Free DevOps Resources

Get DevOps news, tutorials and resources in your inbox. A perfect way If you want to get started with devops. Like you, we dont like spam.