---
title: "Learn from this Grafana Tutorial and Make Data Monitoring Easy"
description: "Learn how to set up Grafana on your machine to monitor services and applications data in this Grafana tutorial effectively!"
canonical: "https://adamtheautomator.com/grafana-tutorial/"
---

# Learn from this Grafana Tutorial and Make Data Monitoring Easy

> Learn how to set up Grafana on your machine to monitor services and applications data in this Grafana tutorial effectively!

Source: https://adamtheautomator.com/grafana-tutorial/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Learn from this Grafana Tutorial and Make Data Monitoring Easy](https://adamtheautomator.com/wp-content/uploads/2022/03/Get-Started-With-Monitoring-in-this-Grafana-Tutorial.jpg)

# Learn from this Grafana Tutorial and Make Data Monitoring Easy

[![](https://secure.gravatar.com/avatar/2beb65fca997135120ed98dc6a2e57dcdf1a7d7d2f5ff687b5d91dc7ccd7a6b5?s=192&d=mm&r=g)Sagar](https://adamtheautomator.com/author/shanky-mendiratta/)21 March 20226 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Grafana](/tag/grafana/)[Monitoring](/tag/monitoring/)

Table of Contents

*   [Prerequisites](#prerequisites)
*   [Installing Grafana on Ubuntu (Command Line)](#installing-grafana-on-ubuntu-command-line)
*   [Adding Data in MySQL Database](#adding-data-in-mysql-database)
*   [Configuring Data Source into Grafana Dashboard](#configuring-data-source-into-grafana-dashboard)
*   [Monitoring Data in Grafana Dashboard](#monitoring-data-in-grafana-dashboard)
*   [Configure different Visualization in the Grafana Dashboard](#configure-different-visualization-in-the-grafana-dashboard)
*   [Conclusion](#conclusion)

In today’s DevOps era, monitoring multi-tier microservices and applications in a data center or cloud infrastructure is important. One of the most widely used monitoring tools is [Grafana](https://grafana.com/docs/grafana/latest/introduction/), and you’ll get started with monitoring in this Grafana tutorial.

Grafana is an open-source tool that performs analysis of logs errors from various sources and centrally manages monitoring. And in this Grafana tutorial, you’ll learn how to install Grafana on your machine, add data in Grafana, and monitor that data.

Ready? Read on and never miss crucial data again!

## Prerequisites

This post will be a step-by-step Grafana tutorial. If you’d like to follow along, you only need an Ubuntu 14.04.4 LTS or greater – This Grafana tutorial uses [Ubuntu](https://adamtheautomator.com/install-ubuntu/) 20.04.3 LTS machine.

Related:[How to Install Ubuntu 20.04 \[Step-by-Step\]](https://adamtheautomator.com/install-ubuntu/)

## Installing Grafana on Ubuntu (Command Line)

Grafana is an open-source tool that supports cloud monitoring vendors, such as Amazon CloudWatch, Microsoft Azure, SQL Db’s and Postgres, and MySQL. But before you query or analyze the data, you’ll first need to install Grafana on your machine.

1\. Connect to your Ubuntu machine using your favorite SSH client.

2\. Next, run the [`apt update`](https://linuxize.com/post/how-to-use-apt-command/#updating-package-index-apt-update) command below to update package repositories in your machine.

```bash
sudo apt update 
```

![Updating Package Repositories](https://adamtheautomator.com/wp-content/uploads/2022/03/image-272.png)

Updating Package Repositories

Related:[A Windows Guy in a Linux World: Setting up SSH in Linux](https://adamtheautomator.com/ssh-command-in-linux/)

3\. Run the following [`apt-get install`](https://vitux.com/how-to-use-apt-to-install-programs-from-command-line-in-debian/) command to install the Grafana dependency packages ( `software-properties-common`, `wget`, [`transport-https`](https://manpages.ubuntu.com/manpages/lunar/en/man1/apt-transport-https.1.html), and [`curl`](https://manpages.ubuntu.com/manpages/trusty/man1/curl.1.html)). You’ll need these packages to download the required Grafana packages later.

```bash
sudo apt-get install -y apt-transport-https curl software-properties-common wget
```

![Installing Grafana Dependency Packages](https://adamtheautomator.com/wp-content/uploads/2022/03/image-273.png)

Installing Grafana Dependency Packages

4\. Now, run the [`wget`](https://linuxize.com/post/wget-command-examples/) command below to add the Grafana GPG Key. Adding the GPG key to your apt installation’s trusted key list lets you download and verify GPG signed packages.

```bash
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
```

Related:[How to Download Files with Python Wget](https://adamtheautomator.com/python-wget/)

Below, you can see an output with an OK message, which confirms the successful addition of the GPG Key.

![Adding the Grafana GPG Key](https://adamtheautomator.com/wp-content/uploads/2022/03/image-274.png)

Adding the Grafana GPG Key

4\. Execute the [`add-apt-repository`](https://linuxize.com/post/how-to-add-apt-repository-in-ubuntu/) command below to add the Grafana repository (`https://packages.grafana.com/oss/deb`) to your APT sources. Adding the Grafana repository allows you to install the Grafana software on an ubuntu machine.

> _If you install from the APT repository, then Grafana is automatically updated every time you run apt-get update_

```bash
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
```

![Adding the Grafana Repository to your APT Sources](https://adamtheautomator.com/wp-content/uploads/2022/03/image-275.png)

Adding the Grafana Repository to your APT Sources

Related:[Learning Ubuntu Apt-Get Through Examples](https://adamtheautomator.com/ubuntu-apt-get/)

5\. Rerun the apt update command below to refresh your APT Cache to update the package list.

```bash
sudo apt update
```

6\. Next, run the [`apt install`](https://linuxize.com/post/how-to-use-apt-command/#updating-package-index-apt-update) command below install the Grafana package.

```bash
sudo apt install grafana
```

![Installing the Grafana Dashboard](https://adamtheautomator.com/wp-content/uploads/2022/03/image-276.png)

Installing the Grafana Dashboard

7\. Run the following `systemctl` command to `start` the Grafana service (`grafana-server`)

```bash
sudo systemctl start grafana-server
```

Related:[Controlling Systemd services with Ubuntu systemctl](https://adamtheautomator.com/ubuntu-systemctl/)

8\. Finally, run the below command to verify the `status` of the Grafana service (`grafana-server`).

```bash
sudo systemctl status grafana-server
```

As you see below, the Grana service is on active (running) status, which indicates Grafana is running correctly.

![Verifying the Grafana Service](https://adamtheautomator.com/wp-content/uploads/2022/03/image-277.png)

Verifying the Grafana Service

## Adding Data in MySQL Database

You’ve just successfully installed Grafana on an Ubuntu machine. So now what? Unless you add data into the data source and configure it in Grafana, you can’t do much with Grafana.

This Grafana tutorial uses MySQL database to store data. But before storing data, you’ll need to install MySQL on your machine.

1\. Run the `apt install` command below to install the MySQL package (`mysql-server`).

```bash
sudo apt install mysql-server
```

2\. Next, execute the below command to check the `status` of `mysql.service` and verify if you’ve successfully installed MySQL on your machine.

```bash
systemctl status mysql.service
```

![Verify if MySQL is Successfully Installed](https://adamtheautomator.com/wp-content/uploads/2022/03/image-278.png)

Verify if MySQL is Successfully Installed

3\. Now, execute the below command to run MySQL software on your machine.

```bash
sudo mysql
```

![Running MySQL](https://adamtheautomator.com/wp-content/uploads/2022/03/image-279.png)

Running MySQL

4\. Run the following command to create a user on MySQL. You can change the username and password as you prefer. But the below command creates the `peterw` user with a password (`jyp12345`), which is granted with all required permissions.

These permissions enable the user to create, insert, or read MySQL data.

> C_reating a new user in the MySQL database assigned with appropriate permissions is always recommended, rather than an admin user._

```bash
create user peterw@localhost identified by 'jtp12345'
GRANT ALL PRIVILEGES ON *.* TO peterw@localhost;
```

![Creating a User with Required Permissions](https://adamtheautomator.com/wp-content/uploads/2022/03/image-280.png)

Creating a User with Required Permissions

5\. Now, run the `FLUSH` command below for user creation and permissions to take effect.

```bash
FLUSH PRIVILEGES;
```

![Flushing Privileges for User Creation and Permission to Take Effect](https://adamtheautomator.com/wp-content/uploads/2022/03/image-281.png)

Flushing Privileges for User Creation and Permission to Take Effect

6\. Run the `mysql` command below to log in to MySQL with user `peterw`.

```bash
sudo mysql -u peterw -p
```

![Logging in to MySQL](https://adamtheautomator.com/wp-content/uploads/2022/03/image-282.png)

Logging in to MySQL

7\. Next, run the query below to create a table (`employee_ATA`) with three columns (`name`, `designation`, and `age`) in a database.

```bash
CREATE TABLE employee_ATA(name varchar(45) NOT NULL,designation varchar(35) NOT NULL,age int NOT NULL);
```

![Create table employee](https://adamtheautomator.com/wp-content/uploads/2022/03/image-283.png)

Create table employee

8\. Lastly, run each `INSERT` query below to add data in the `employee_ATA` table. The below commands add three entries to the database within the `name` column (`AdamBertram`**,** `AdamListek`**,** and `ShankyMendiratta`**)**.

```bash
INSERT INTO employee_ATA (name,designation,age) VALUES ( 'AdamBertram', 'Founder_of_ATA', 40);
INSERT INTO employee_ATA (name,designation,age) VALUES ( 'AdamListek', 'Director_of_ATA', 38);
INSERT INTO employee_ATA (name,designation,age) VALUES ( 'ShankyMendiratta', 'Tech_Writer_of_ATA', 32);
```

![Adding Data in MySQL Database](https://adamtheautomator.com/wp-content/uploads/2022/03/image-284.png)

Adding Data in MySQL Database

## Configuring Data Source into Grafana Dashboard

You previously installed Grafana, but how do you know Grafana is running? A default login web page is available to verify that the server is correctly running with the service started.

1\. Open a web browser, and navigate the URL below to access the Grafana default web interface. Replace `MachineIP` with your machine’s IP address.

```bash
<MachineIP>:3000
```

2\. Next, provide the email or username as **admin** and password as **admin**, then click on the login button to log in to the Grafana dashboard.

![Accessing Grafana Dashboard](https://adamtheautomator.com/wp-content/uploads/2022/03/image-285.png)

Accessing Grafana Dashboard

Once you’re in, you’ll get to the Grafana dashboard, as shown below.

![Logging into Grafana Dashboard](https://adamtheautomator.com/wp-content/uploads/2022/03/image-286.png)

Logging into Grafana Dashboard

3\. Click on the Settings icon (gear icon), and choose Data sources. Doing so redirects your browser to a page where you can configure the data sources (step four).

![Adding Data Sources in Grafana](https://adamtheautomator.com/wp-content/uploads/2022/03/image-287.png)

Adding Data Sources in Grafana

4\. Now, click on **Add data source**, and choose MySQL from the list of data sources you’ll see, as shown below.

![Configuring the MySQL as the data source in the Grafana Dashboard](https://adamtheautomator.com/wp-content/uploads/2022/03/image-288.png)

Configuring the MySQL as the data source in the Grafana Dashboard

5\. Provide the details for the data source:

*   The name of the database (`mysql`).
    
*   The User (**peterw**) and password you configured in the “Adding Data in MySQL Database” section (step four).
    
*   Click on **Save and Test** to save the details and test if the database connection works.
    

As shown below, you can confirm the successful addition of the MySQL data source.

![Configuring MySQL Data Source in Grafana](https://adamtheautomator.com/wp-content/uploads/2022/03/image-289.png)

Configuring MySQL Data Source in Grafana

## Monitoring Data in Grafana Dashboard

Up to now, you’ve configured Grafana with MySQL as the data source. So it’s time to test if everything is integrated correctly and monitor the Grafana Dashboard.

1\. Click on the **+** icon at the left panel, and create a new Grafana Dashboard, as shown below.

![Creating the Grafana Dashboard ](https://adamtheautomator.com/wp-content/uploads/2022/03/image-290.png)

Creating the Grafana Dashboard

2\. Next, click on **Add a new Panel** option in the new dashboard, as shown below, which redirects the browser to the **Edi Panel** page (step three).

![Adding a new Panel in the dashboard](https://adamtheautomator.com/wp-content/uploads/2022/03/image-291.png)

Adding a new Panel in the dashboard

3\. On the **Edit Panel** page, select the Data source as **MySQL**, then click on the Edit button (pencil icon) to open a code box where you’ll put in a query (step four).

![Selecting MySQL as Data Source](https://adamtheautomator.com/wp-content/uploads/2022/03/image-292.png)

Selecting MySQL as Data Source

4\. Finally, copy/paste the below code in the code box, choose the **Format** as **Table**, and click on Apply (top-right) to apply the query.

The below query will publish all data (SELECT \*) that resides inside the employee\_ATA table.

```bash
SELECT *
FROM employee_ATA
```

![Editing the query and applying changes ](https://adamtheautomator.com/wp-content/uploads/2022/03/image-293.png)

Editing the query and applying changes

After applying the query, you’ll see the panel below in the Grafana dashboard showing all the employees, their ages, and the designation of each employee.

Notice there are multiple visualizations that Grafana provides you a suggestion to incorporate into your dashboard.

![Viewing Multiple Visualizations that the Grafana Dashboard Provides](https://adamtheautomator.com/wp-content/uploads/2022/03/image-294.png)

Viewing Multiple Visualizations that the Grafana Dashboard Provides

> _You can also view the same data in tabular format if you select the Table view on the same page, as shown below._

![Viewing the Data of employee\_ATA Table in Table View](https://adamtheautomator.com/wp-content/uploads/2022/03/image-295.png)

Viewing the Data of employee\_ATA Table in Table View

## Configure different Visualization in the Grafana Dashboard

Previously you saw how Grafana generates the data in table format as well as in graphical mode. By default, Grafana provides potential suggestions for Dashboard configuration, based on the selected data source. To further demonstrate this, shown below are two of the visualizations that are most widely used, Bar and Gauge charts.

When you need to display the Dashboard in the Bar chart format you will need to select the bar chart in the visualization, for example, the age of all users in the `employee_ATA` table are shown in bar format.

![Displaying the data in the Bar chart](https://adamtheautomator.com/wp-content/uploads/2022/03/image-296.png)

Displaying the data in the Bar chart

Similarly, choose the Gauge format for a different visualization option. To help determine visual warning conditions, set the threshold and assign the values to a color.

As you can see in the below image, the three selected users have ages greater than 32, hence why yellow is present in each representation. But for the age greater than 40 only Adam Bertram crosses the assigned threshold so his user is represented in Red color.

![Displaying the data in the Gauge format with the threshold set](https://adamtheautomator.com/wp-content/uploads/2022/03/image-297.png)

Displaying the data in the Gauge format with the threshold set

## Conclusion

In this Grafana tutorial, you’ve learned how to set up Grafana and monitor the data stored in MySQL using Grafana. You also learned how to view the data in various visualizations in different panels within the Grafana Dashboard.

Now that you have a fully functional Grafana Dashboard in your machine, what do you plan to monitor next in your Grafana Dashboard?

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fgrafana-tutorial%2F&text=Learn%20from%20this%20Grafana%20Tutorial%20and%20Make%20Data%20Monitoring%20Easy)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fgrafana-tutorial%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fgrafana-tutorial%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2022/04/Getting-Started-with-Grafana-Prometheus-Kubernetes-Cluster-Monitoring-1.jpg)

### [Utilizing Grafana & Prometheus Kubernetes Cluster Monitoring](/prometheus-kubernetes/)

Learn how to effectively monitor your Grafana and Prometheus Kubernetes cluster in this tutorial!

![](https://adamtheautomator.com/wp-content/uploads/2023/01/pandora-fms.jpg)

### [Discover Proactive Linux Monitoring with Pandora FMS](/pandora-fms/)

Learn about how Pandora FMS is a powerful Linux monitoring tool that helps admins stay ahead of problems, identify trends, and optimize system performance.

![](https://adamtheautomator.com/wp-content/uploads/2022/12/aws-grafana.jpg)

### [Discover Managed Data Visualizations With AWS Grafana](/aws-grafana/)

Learn how to leverage a managed data visualization tool and observability platform with AWS Grafana in this ATA Learning tutorial!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
