Grafana is one of the most popular platforms for creating dashboards and graphs for visualization and analysis. You can build dashboards that have panels, with each of them being a representation of specific metrics within a specific time frame. Grafana can also be used in several other domains, namely, weather control, automation of homes, and industrial sensors. This is mainly because it offers an excellent platform to help users build and share dashboards and data, not only with your team, but also worldwide. In this article I will guide you on how to add Prometheus dashboard to your Grafana. You will also learn how to install Prometheus statistics dashboard that has already been configured to your Grafana.
Requirements
To effectively follow this guide, you need:
- Ubuntu 14.04 droplet
- User that can access sudo—the initial server setup with Ubuntu will provide you with details
- Prometheus and Grafana 2.5+—the software has to be installed
Step 1: Add Prometheus as a Grafana data source
This is when Grafana is configured to allow you to access your Prometheus as a data source. Every Prometheus server represents a different data source. Therefore, if the configuration you are carrying out is of more than a single server, then repeat the procedure below for each server.
Visit the Grafana main view at http://your_server_ip:3000/, and then sign into the administrator account.
The Grafana icon located at the top left corner of your screen will provide you with the main menu. Click on “Data Sources” and you will find the data sources list page. Click on “Add New” in the navigation bar. The following details will help you add a new data source:
- Name: Prometheus
- Type: Prometheus
- URL: http://<your_server_ip>:9090
- Access: proxy
Click on “Add Data Source” after inserting the above values.
Step 2: Import Prometheus stats dashboard
At this step, you will download a pre-configured Prometheus stats dashboard and then import it to the Grafana platform.
Download Prometheus at http://grafana.com/dashboards?datasource=prometheus
You will find the import page on the dashboard picker dropdown. Click on “Choose File” and then import the already downloaded Prometheus dashboard found in your local files. If the configuration on Prometheus has been done correctly, you will see the Prometheus stats dashboard page and even be in a position to view statistics from the Prometheus server. Remember to click on the “Save” button so that your dashboard will be saved in Grafana. You will lose your dashboard if you do not save it before you close the browser.
Step 3: View the Prometheus statistics dashboard
The moment you have successfully imported the downloaded dashboard, you will be taken to a new dashboard page, which will be unsaved at this moment. This dashboard, which was developed by Prometheus, provides the essential metrics that can help troubleshoot the Prometheus server. The metrics found here include:
Scrapes
This provides you with scrape data from instrumented jobs. There is a target scrape graph that shows you the frequency at which targets are scraped over a specific period of time—usually 5 minutes per the time series of a specific range vector.
Rule eval duration
This is a graph that shows the time all evaluations take to be successfully executed. The graph provides you with three percentiles (50th, 90th, and 99th), displayed in three distinct ways to help determine the outliers that can skew your data.
Step 4: Analyze data from the Prometheus dashboard
The graphs that have been generated by new Prometheus servers are usually flatter and smaller. In the long run, these graphs will have a huge variation, and this entirely depends on how you use each of the servers and the workload they handle. It is important to have some stability in these graphs. Scraping more targets or exporting more metrics will increase memory series and the ingested samples. Similarly, if the scrape latency in the graphs increases, it is important to find out the reason behind the increase. You have to figure out whether an app scaled up or if it was instrumented in a bad way.
Step 5: Customize the graphs and metrics
At this stage, the Prometheus dashboard has been added to your Grafana with a statistics server that has already been configured. Grafana will allow you to visualize any form of data or metrics that is found on the Prometheus dashboard. There is a Prometheus query editor on the dashboard, which allows Grafana access to all the metrics. The Prometheus query editor can be accessed by clicking on the panel title area, which provides you with the panel menu. Click on “Edit” and you will find all the metric tabs. You will not only gain direct access to queries, but also to all the available options for the Prometheus data source.
About the Writer
Steve Patrick is a freelance writer with a keen interest in computing and technology. He writes articles, guides, and blog posts on data science and engineering, among other areas. You can read some of his pieces on the website for Active Wizards, a market leader company in Data Science and Machine Learning.