Grafana is one of the leading open-source tools for running application analytics, visualizing metrics, and time-series data. It gives us the tools we need to monitor and analyze the database, allowing us to detect and address the issues. In this Grafana tutorial, you will learn the core concepts of Grafana.
Grafana is a freeware, multi-platform analytics, and visualization solution. Irrespective of the data storage location, we can explore, query, and visualize the data. It offers you the tools to transform your time-series database into excellent visualization and graphs.
Organizations utilize Grafana to monitor their log and infrastructure analytics, largely to enhance their functional effectiveness. Dashboards track events and users because they automate the management, viewing, and collection of data.
Security Analysts, Developers, and Product Leaders use this data to make their decisions. If you want to learn more about Grafana, Join our Grafana training. This tutorial discusses dashboard creation, environment configuration, and more of Grafana.
Before we start, let us have a look at what we will be discussing in this article:
Grafana Tutorial - Table of Content |
Grafana is a database monitoring and analysis tool. It enables us to build dashboards visualizations of the essential measures that we need to analyze. It has a good community of enthusiasts who will share recyclable dashboards.
It supports various data types, and as it is freeware, we can assure that the moment a new data source has been released, someone will support it. The most general use case of Grafa is visualizing the time series data, like CPU over time or memory.
We can host the Grafana ourselves through the Managed Services in AWS or use Creators for hosting for you. Grafana executes the process on our server or computer, and we can access the interface through our browser. The dashboard can display the data as graphs, heat maps, single numbers, or charts.
If you want to enrich your career and become a professional in Grafana, then enroll in "Grafana Online Training" - This course will help you to achieve excellence in this domain. |
The steps for installing Grafana depend on where we run the Grafana. We regularly run this kind of application locally to see how it works before running remotely. It offers detailed instructions for wherever we need to deploy it.
On the Windows platform, we can install Grafana either through a Standalone library file or a Windows installer package.
For running Grafana, open the browser and go to Grafana port, and subsequent follow the below instructions:
Step1: Install the Grafana
We can install it on different operating systems. Following are some hardware and software requirements:
Hardware Requirements
Software Requirements
Grafana needs a database for storing its configuration data like data sources, dashboards, and users. It supports the below databases:
Step2: Login
For logging into the Grafana for the first time:
Installing With Homebrew
Use Homebrew for installing the recent version of the Grafana through the Homebrew package.
Step1: On the Homebrew homepage, search for Grafana. The latest version of Grafana is listed.
Step2: Open the terminal and enter
brew update
brew install grafana
Brew page downloads and goes into the following files
/usr/local/cellar/grafana/[version] (Homebrew v2)
/opt/homebrew/cellar/grafana/[version] (Homebrew v3)
Step3: Start the Grafana through the command:
brew services start grafana
Related Article: Advanced Grafana Interview Questions |
For installing the Grafana latest version without Homebrew, go to “Grafana Download Page” and follow these steps:
Step1: Choose the Grafana version we have to install. By default, the latest version is chosen.
Step2: Select the Edition
1. Open Source: The functionality is similar to the enterprise edition; however, we have to download the enterprise edition if we have enterprise features.
2. Enterprise: It is the most appropriate version for users. The functionality of the Enterprise edition is similar to the open-source edition; however, it includes the feature we can unlock with the license if we want to select.
Step3: Press “Mac”
Step4: Open the terminal and download the binary file through the cURL command. The following command displays Grafana 7.1.5 version:
Curl -0 https://d1.grafana.com/oss/release/grafana-7.1.5.darwin-amd64.tar.gz
Step5: Enter the “gz” file and copy files to a location of our preference.
Step6: For Starting the Grafana service, open the directory and execute the command:
./bin/grafana-server web
Configuring the data source is the first step in building Grafan dashboards. Our data source can be the database or the collection of logs. It supports various data sources from traditional data sources MySQL to the log aggregation platforms like the AWS Cloudwatch.
Now we will configure the Grafana for connecting to our MySQL database. For instance, I have created the database named “CD” with the table known as “Artist” for simulating the database of an application.
Now, we have to add the Grafana user to the database. In MySQL database, the database administrator will execute the following for adding the read-only user with name “GrafanaReader” to our database “CD” for table “Artist.”
For adding the link from our database to the Grafana, go back to the Grafana interface.
The first option below is “Create our first data source” Complete the web form with our connection details. Complete web form with connection details. If we are using the local MySQL database running on the localhost on port 3306 for database “CD” and with the user name “GrafanaReader,” It is safe to leave the remaining fields as default.
Press save and test. If we configured everything correctly, we must see the green box with the message “Database Connection OK.”
A Dashboard offers you a detailed view of the data and allows us to track the measures using different visualizations. Dashboards contain panels that represent a part of the story we want our dashboard to convey. The intent of the Grafana dashboard is to bring the data together in a way that is both organized and efficient.
It enables the users to understand the measure of our data using queries, detailed visualizations, and alerts. Grafana also helps us share the dashboards with others, enabling us to analyze the data together.
Another important feature of Grafana dashboards is freeware, which enables for more power and personalization, subject to how affluent with coding. Yet, we do not require comprehensive knowledge of coding for creating our completely working dashboards.
We use Grafana Dashboard templating to make our dashboard more responsive. Briefly, we build dashboard templates variables that we can use nearly everywhere in the Grafana Dashboard. The usage of these variables enables us to induce dynamic, which considerably augments the usefulness and effect of Grafana.
Each panel contains a visualization and a query. The query specifies what data we have to display, while the visualization specifies how we show the data.
Step1: In the sidebar, hover the cursor on the “create” icon and next press “Download.”
Step2: Press “Add New Panel.”
Step3: In Query Editor of the graph, type the query from earlier, and next click “Shift+Enter”:
Step4: In the “Legend” field, type “route” for renaming the time series in the time legend. Graph legend updates when we press outside the field.
Step5: In the Panel editor of right, in Settings, modify the panel title to the “Traffic.”
Step6: Press “Apply” in the top-right corner to save the panel and revert to the dashboard view.
Step7: Press the “Save Dashboard” icon at the top of the dashboard for saving our dashboard.
Step8: Enter the name in the “New Name” field and next press “save.”
Panels are the constituent elements of Grafana. They enable us to visualize the data in various ways. Although Grafana has multiple kinds of in-built panels, we can also build our panel to support our visualizations.
Before we start building plugins, and we have to set up our environment for developing plugins. For discovering plugins, Grafana scans the plugin directory, the location of which relies on the operating system.
Step1: Create a directory known as “Grafana -plugins” in our chosen location
Step2: Discover the “plugins” property in the Grafana configuration file and set “plugins” property to the path of our “grafana-plugin” directory.
Plugins = “/path/to/grafana-plugins”
Step3: Restart the Grafana if it is already working for loading the new configuration.
To create a new plugin, we will use “Grafana-toolkit.” Grafana-toolkit is the CLI application that streamlines the Grafana plugin development to concentrate on code. Toolkit deals with testing and building
Step1: In Plugin Directory, Create the plugin from the template through the “plugin: create” command:
npx @grafana/toolkit plugin:create my-plugin
Step2: Change the directory:
cd my-plugin
Step3: Download the required dependencies:
yarn install
Step4: Develop the plugin
yarn dev
Step5: Restart the Grafana server for Grafana for discovering our plugin.
Step6: Open the Grafana and go to the “Configuration/Plugins.” Assure that your plugin exists.
Generally, Grafana logs anytime it finds a plugin
Grafana supports more than 26 queries per panel. Grafana relies on the appropriate query language for the data source. That can be Prometheus SQL, InfluxQL, PromQL, PostgreSQL’s SQL variant, Elasticsearch Query DSL, InfluxQL, etc.
In the query selection tab of Grafana’s UI, we can select the data source to use. It will show whatever data sources we already associated with our iteration of the Grafana. We can choose the mixed option to query from multiple sources simultaneously.
A data source in the Grafana must extend “DataSourceAPI,” which needs you to specify two methods: “query” and “test data source”
“Query” method
The query method is the core of every data source plugin. It receives the query from the user, gets the data from the external database, and gets the data in the format that Grafana identifies.
The “Options” object includes the targets or queries that we made, along with the environment data, along with the background data, like the current time interval. We will use this information to query the external database
“test data source” deploys the health check for the data source. For instance, Grafana calls this method whenever the user presses the “Save&Test” button after modifying the connection settings.
Prometheus is a freeware data monitoring tool. The combination of Grafana and Prometheus is the de facto tool combination used for deploying the data visualization environment. We use Grafana Dashboards to visualize the data while the backend is controlled by the Prometheus. Although Prometheus also has data visualization features, yet, Grafana is chosen for visualizing the data. Prometheus is suitable to store the time series data.
Our Grafana helps you install and configure the Grafana. It also enables you to create dashboards and plugins. I hope this information is sufficient for getting the fundamental idea about Grafana. If you have any queries, let us know by commenting below.
Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:
Name | Dates | |
---|---|---|
Grafana Training | Nov 23 to Dec 08 | View Details |
Grafana Training | Nov 26 to Dec 11 | View Details |
Grafana Training | Nov 30 to Dec 15 | View Details |
Grafana Training | Dec 03 to Dec 18 | View Details |
Viswanath is a passionate content writer of Mindmajix. He has expertise in Trending Domains like Data Science, Artificial Intelligence, Machine Learning, Blockchain, etc. His articles help the learners to get insights about the Domain. You can reach him on Linkedin