Table of Contents
Overview of Grafana and Prometheus
Let us get an insight into how Grafana and Prometheus work together for monitoring metrics. Application monitoring is a crucial feature for any successful software offering. Application monitoring in its simplest form refers to collecting metrics on an application and using those metrics to gain an insight to improve the performance and efficiency of the application.
Think of it as a cycle.
- First, we collect usage metrics on an application.
- Then use those metrics to generate information.
- This then enables application developers and other stakeholders to better understand the application and user behavior, identify bugs and usage patterns, and so much more.
- Understanding these patterns then aid in decision-making towards application improvement. Examples include scaling the application during a surge or changing the language on certain buttons to drive up button clicks.
- Then we continue collecting metrics to ensure our changes had the desired effect..., and the cycle continues.
Grafana and Prometheus are probably the most prominent tools in the application monitoring and analytics space. Prometheus is an open source monitoring and alerting platform which collects and stores metrics as time-series data
Grafana is an open source analytics and interactive visualization web application. It allows you to ingest data from a huge number of data sources, query this data, and display it on beautiful customizable charts for easy analysis. It is also possible to, set alerts so you can quickly and easily be notified of abnormal behavior and lots more.
Judging from what they are, one can easily infer that Prometheus is used to collect and store metric data from client applications, and this data is then available to be analyzed and visualized using Grafana. This forms the basis of the perfect combo in application monitoring, the Prometheus - Grafana relationship, which we intend to dive deeper into over the course of this article.
MetricFire offers Hosted Prometheus and Hosted Grafana, so you can use these products in tandem with minimal configuration to gain in-depth insight into your applications. If you would like to speak with our experts, book a demo with us, or sign up for the free trial today.
Prometheus as a Grafana datasource
As earlier discussed, Grafana is simply a visualization and analytics tool. It possesses powerful capabilities in processing metric data into information that can be easily understood and acted upon at a glance, using graphs or other forms of visualization.
But this data would have to come from somewhere, bringing us to the concept of Grafana data sources. Grafana has built-in support for a good number of different storage options for time series data. These options are called data sources and they essentially serve as data stores that feed metric data collected from applications, into Grafana.
Prometheus is one such data source, possibly the most popular data source option for Grafana.
The following points outline the steps to add Prometheus as a data source in your Grafana dashboard, but keep in mind that it would require you to have an admin role in your organization.
- Click the "cogwheel" icon in the top right corner of your Grafana dashboard to open the configuration menu.
- Click on "Data Sources" in the left panel, then click on "Add data source".
- Select "Prometheus" as the data source type.
- Specify the URL of your Prometheus server, for example. http://prometheus.example.org:9090.
- Insert other data source settings as needed (for example, specifying the data source name, username, and password, or access type).
- Click "Save & Test" to save your new Prometheus data source.
After connecting your Prometheus instance to Grafana as a data source, the next logical step would be to feed your actual metric data into Grafana. This will process the data into a more readable format, for example, a graph.
The following steps outline this process:
- Click the “Add panel” button at the top right of your Prometheus dashboard, then click the “Add new panel” button within the new blank panel that showed up on the dashboard.
- Specify the panel title in the right pane of your configuration page
- Select your Prometheus data source from the dropdown under the “Query” tab.
- Enter a valid Prometheus expression in the PromQL field for the metric data you wish to display in the graph. If you are unsure what exact metric names to place within your query, you can simply use the “Metrics” dropdown button to the left of your PromQL field to look up metric names to insert in your query. For more on writing PromQL queries, check out this article
- You can fill out the remaining data such as the legend, Min step or format as you see fit.
- Click “Apply” on the top right of the panel settings page to see your graph added to your Prometheus dashboard.
Worthy of note is the fact that PromQL also supports templating and variables. Basically, variables are entities that help to create dynamic charts. They are simply value placeholders. For example, rather than hard coding things like application, server, or even metric names in your metric queries, you could store these values in variables, and then use these variables in your queries.
Queries with variables embedded in them are called templates. Using templates, you can change the data displayed on a graph by simply changing the value of variable(s) within the template, thus creating a dynamic chart. Variables are displayed as a dropdown list at the top left of the dashboard, so switching between variables is as simple as selecting a new value from the dropdown.
Hosted Grafana and Prometheus by MetricFire
Prometheus and Grafana individually are amazing products, but when used together, they become even more powerful in providing you amazing insight into your application performance. But both these products are open source applications.
With all open source applications, they come with the hassle of having to install, maintain and upgrade them yourself. This introduces a significant management overhead, especially when dealing with large amounts of data.
However, with a hosted offering, this overhead is drastically reduced, if not wiped out altogether.
MetricFire provides managed Grafana and Prometheus offerings. These are cloud hosted instances of Prometheus and Grafana, ready to go right off the bat. These offerings are completely maintained and upgraded by MetricFire.
MetricFire eliminates the need for manual update and maintenance cycles that would be traditional for normal open source applications, leaving you to focus solely on monitoring your system.
Sign up for a free trial today to take our Hosted Grafana and Hosted Prometheus for a spin, or schedule a demo to speak to a member of our team.