Grafana
4.0 (172 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
1,216 students enrolled

Grafana

Learn Grafana, the leading open source tool for visualizing metrics, time series data and application analytics.
4.0 (172 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
1,216 students enrolled
Created by Sean Bradley
Last updated 7/2020
English
Current price: $15.29 Original price: $199.99 Discount: 92% off
30-Day Money-Back Guarantee
This course includes
  • 4 hours on-demand video
  • 2 Practice Tests
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Explore the Graph, Singlestat, Gauge, Bar Gauge, Table, Text, Heatmap and Logs Panels
  • Install and configure a MySQL Datasource, Dashboard and Collector
  • Install and configure a Zabbix Server Datasource, Dashboards
  • Install and configure InfluxDB with Telegraf
  • Use Dashboard Variables to create Dynamic Dashboards with Automatic Visualisation Placement
  • Install an SNMP Agent and Configure Telegraf SNMP Input
  • Install Loki Data Source that queries a Loki Service that is ingesting data from a Promtail Service.
  • Graph Time Series aswell as Non Time Series SQL Data
  • Create custom MySQL Time Series Queries
  • Install Grafana from Packages
  • Create a domain name, install an SSL certificate and change the defaullt port for the Grafana Server
  • Explore the Dashboards Panels Options
  • Install a SMTP server and setup an Email Notification Channel
  • Setup Alerts for when SNMP devices go offline or return no data
  • Setup a SMS Alerting Channel using AWS SNS
  • Setup a Telegram Bot Alerting Channel
  • Use Annotation Queries to Link Logs Panels and Graph Panels
  • Install Prometheus with Several Node Exporters and A Dashboard
  • Setup Different Value Groups/Tags for Zabbix and InfluxDB Datasources
  • Create a Disk Read/Write Rates Dashboard with the Zabbix Data Source
Requirements
  • Basic Linux Experience
  • Basic MySQL Familiarity
  • All commands entered during the lectures are provided in the corresponding resources
Description

Welcome to my course on Grafana

Grafana is the leading open source tool for visualizing metrics, time series data and application analytics.

I demonstrate many things in this course, with all the example commands provided for you to easily copy and paste.

This is a Learn by example course, where I demonstrate all the concepts discussed so that you can see them working, and you can try them out for yourself as well.

With this course, comes accompanying documentation that you can access for free. You will then be able to match what you see in the videos and copy/paste directly from my documentation and see the same result.

In this course we will,

  • Install Grafana from Packages

  • Create a domain name, install an SSL certificate and change the default port

  • Explore the Graph, Singlestat, Gauge, Bar Gauge, Table, Text, Heatmap and Logs Panels

  • Create many different types of Data Sources from MySQL, Zabbix, InfluxDB, Prometheus and Loki

  • We will configure their various collection processes such as MySQL Event Scheduler, Telegraf, Node Exporters, SNMP agents and Promtail

  • We will look at graphing Time Series data versus Non Time Series data

  • We will also install dashboards for each of the Data Sources, experimenting with community created dashboards plus experimenting with our own

  • We will monitor SNMP Devices using Telegraf Agent and InfluxDB Data Sources

  • We will create Annotation Queries and link the Log and Graphs panels together

  • We will look at Dynamic Dashboard Variables, Dynamic Tables, Dynamic Singlestats and Dynamic Graphs

  • We will look at creating Value Groups/Tags and how to use them with different kinds of data sources

  • We will set up an alerting channel, understand the different alerting options, configure an example of it to detect offline SNMP devices and demonstrate receiving email alerts via our local SMTP server

  • We will then create a dashboard for a 24 port Cisco Switch using methods applicable to both the Zabbix and the InfluxDB Data Sources

At the end of the course, you will have your own dedicated working Grafana Server, which will be in the cloud, with SSL, a domain name, with many example Data Sources and collectors configured, that you can call your own, ready for you to take it to the next level.

Once again, this is a Learn by example course, with all the example commands available for you to copy and paste. I demonstrate them working, and you will be able to do that to.

You are now ready to continue.

Thanks for taking part in my course, and i'll see you there.

Who this course is for:
  • Network, Systems and Database Administrators
  • Infrastructure Monitoring Specialists
  • IT Platform Specialists
  • DevOps Technicians
  • Enthusiasts wanting a better understanding and better visibility of their networks in the home or office
  • Someone who is curious and wants a good understanding of what Grafana does and what it's good at.
Course content
Expand 49 lectures 04:00:56
+ Introduction
49 lectures 04:00:56

The official documentation for this course is hosted for FREE at https://sbcode.net/grafana. I have written it specifically to be used by the students of this course.

In this course all my examples are executed on an unrestricted Ubuntu 18. You can get minimal Ubuntu 18 server from cloud providers. 
In this course I used Digital Ocean, with this link https://m.do.co/c/23d277be9014, you will normally get $50 credit for 30 days, occasionally the offer changes, but can create and delete as many VMs as you wish during the initial offer period.

Preview 03:06

Grafana is excellent for monitoring time series data.

In this video, I will install Grafana


After the successful install, you can start the Grafana service

$ sudo service grafana-server start


Your Grafana server will be hosted at

http://[your Grafana server url]:3000


The default login,

Username : admin

Password : admin

Install Grafana
05:26

Random Order Grafana Questions

Grafana Questions
7 questions

Using my Domain name provider, I create an A name record pointing to my Grafana server IP.

Point Domain Name
02:37

I add SSL to the Grafana web server to ensure all traffic is encrypted between the server and web browser.

I use LetsEncypt by following the Certbot instructions.

For Web Server software, I choose 'none of the above'

for Operating system, I choose 'Ubuntu 18.04 LTS'

I SSH onto the server,

I enter these commands

$ sudo apt-get update

$ sudo apt-get install software-properties-common

$ sudo add-apt-repository universe

$ sudo add-apt-repository ppa:certbot/certbot

$ sudo apt-get update

then

$ sudo apt-get install certbot

I temporarily stop the Grafana server

$ sudo service grafana-server stop

then run

$ sudo certbot certonly --standalone

I follow the prompts, and enter my domain name I want to secure,


I then copy the certificates over to the granafa folder, and edit the Grafana.ini file to use them, and then start the Grafana server again,

$ sudo service grafana-server stop

And now I visit my Grafana server URL replacing http with https.


Add SSL
03:52

I change the default Grafana web server port from 3000 to 443 since we now have an SSL certificate bound.

I use the iptables prerouting method

$ sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 3000

You can inspect the iptables settings using

$ iptables -t nat -L


Change Default Port
01:29

Random Order Grafana Questions

Grafana Questions
4 questions

I use the 'TestData DB' data source. This is perfect for beginning to learn Grafana.

Create out First Data Source
02:30

We add a panel to the existing TestData DB dashboard, and more specifically, we first look at managing rows and the various presentation options we have.

Panel Rows
01:53

We look at some of the presentation options for panels, such as positioning, size, keyboard shortcuts, duplication, deleting and more.

Panel Presentation Options
01:39

We explore the Graph panel.

Graph Panel
07:56

Show a single value in a series.

Stat Panel
03:36

We explore the Gauge panel.

Gauge Panel
02:05

We explore the Bar Gauge panel.

Bar Gauge Panel
02:44

The Singlestat Panel allows you to highlight a statistic in a single series.


It reduces the series into a single number (by looking at the min, max, average, time, curent value and more in the series).


Singlestat also provides thresholds to color the statistic or the Panel background.


It can also translate the single number into a text value.

Singlestat Panel
07:12

We explore the Table panel.

Table Panel
04:22

We explore the Text Panel and the Markdown syntax used to format the text in the panel.

Text Panel
04:02

We explore the Heatmap Panel

Heatmap Panel
03:44
Grafana Questions
7 questions

I create a new MySQL Data Source.

I also demonstrate how to install a MySQL database server in case you don't have one.

I install the MySQL database on my existing Grafana Server to make it easier to follow the lecture.

You can install MySQL on any server you like.

$ sudo apt install mysql-server

$ sudo mysql_secure_installation

$ sudo service mysql status

I also create an example database, and a specific user called grafana@localhost, thatr will have SELECT only access to the database.

$ mysqladmin create exampledb

$ mysql

  > CREATE USER 'grafana'@'localhost' IDENTIFIED BY 'password';

  > GRANT SELECT ON exampledb.* TO 'grafana'@'localhost';

  > FLUSH PRIVILEGES;

  > quit


I then continue setting up the MySQL data source using the Grafana User Interface.


Create a MySQL Data Source
04:12

Now we have a MySQL Datasource created, we will install a dashboard for it.


The dashboard will be the popular 2MySQL Simple Dashboard you can download from https://grafana.com/grafana/dashboards?dataSource=mysql


Before installing the dashboard, we need to set up a collector on our MySQL server.

The collector script is downloaded from https://github.com/meob/my2Collector


I have MySQL 5.7, so I will download the file called my2.sql

If you have MySQL 8, then download my2_80.sql


I download the script using wget,


$ wget https://raw.githubusercontent.com/meob/my2Collector/master/my2.sql


The event scheduler will also need to be enabled on your MySQL server.

You can do this by editing the my.cnf file

$ nano /etc/mysql/my.cnf


Add lines

[mysqld]

event_scheduler = on


Save, and restart,

$ sudo service mysql restart


Open the script that was downloaded,

$ nano my2.sql


Uncomment the last 2 lines.

Set the password to something you want, and save


Run the sql script,

$ mysql < my2.sql


Open MySQL and so some checks.


$ mysql

> show databases;

> show variables where variable_name = 'event_scheduler';

> use my2;

> show tables;

> select * from current;

> select * from status;

> quit


If everything is ok, continue

Import the new dashboard using the Grafana GUI as shown in the video,

I have an error after installing the Dashboard, that the 'select' command is denied for user 'grafana@localhost'

I need to grant select to the user on the new database 'my2' which was created when running the my2.sql script.


$ mysql

> GRANT SELECT ON my2.* TO 'grafana'@'localhost';

> FLUSH PRIVILEGES;

> quit


Reopen the dashboard, and you should begin to see data.


Note that there are now 2 database users,

  • grafana@localhost
    Used by the Grafana dashboard, to query the collected data from the MySQL server. This user has been granted the SELECT privilege only.

  • my2@localhost
    Used by the MySQL event scheduler to collect statistics and save them into the DB for use by the Grafana dashboard. This user has been granted ALL privileges.







Install a MySQL Dashboard and Collector
11:43

We create a custom MySQL time series query that reads data from a our table in our MySQL database and formats the result set in a way that Grafana can use as a time series result set, and present that data in a graph along with the ability to filter that data using the Grafana user interface time filter drop down.

Preview 09:04

Grafana graphs Time Series data from many types of data sources extremely well.

But sometimes you just want to graph, simple non time series data. i.e., Data without timestamps, flat tables that show simple statistics or values.



Graphing Non Time Series SQL Data in Grafana
06:10

1st Create a MySQL Data Source that will connect directly to the Zabbix Servers MySQL Database.

SSH onto the Zabbix Server,

create a user in MySQL, with read only access, that the Grafana MySQL data source will use to connect with.

$ mysql

> CREATE USER 'grafana'@'YOUR GRAFANA SERVER IP ADDRESS' IDENTIFIED BY 'password';

> GRANT SELECT ON zabbix.* TO 'grafana'@'YOUR GRAFANA SERVER IP ADDRESS';

> FLUSH PRIVILEGES;

> QUIT;


Also allow remote connections on MySQL

$ nano /etc/mysql/mysql.conf.d/mysqld.cnf

Change

bind-address = 127.0.0.1

to

bind-address = 0.0.0.0


Restart MySQL

$ sudo service mysql restart


I then finish and save the MySQL data source for Zabbix.


Now it's time to install the Zabbix Data Source plugin that will connect to the Zabbix API, and also use the new MySQL data source we just created.


I SSH onto the Grafana Server and add a Zabbix Data Source plugin using the CLI

$ grafana-cli plugins install alexanderzobnin-zabbix-app


And then restart the Grafana server


$ sudo service grafana-server restart


I then use the Grafana UI to enable the Zabbix Data Soure Plugin, and then configure it.

The required API URL will be,

https://[your zabbix server ip or domain name]/zabbix/api_jsonrpc.php


Also select the 'Direct DB Access' to be the new MySQL Datasource you just created.


Save and Continue




Create and Configure a Zabbix Data Source
08:17

We import the 3 supplied Zabbix Dashboards

  1. Zabbix System Status

  2. Zabbix Template Linux Server

  3. Zabbix Server Dashboard

Import Zabbix Dashboards
01:49

We create a custom dashboard using our Zabbix data source, and we use many different regex queries to select the data we wish to see.

Create Advanced Custom Zabbix Dashboard
05:39
Grafana Questions
5 questions

We are going to install InfluxDB, the InfluxDB data source, a Telegraf agent and then collect data from some SNMP devices.

InfluxDB is a database useful for storing large amounts of timestamped data.

Telegraf is an agent that support plugins and it will save it's data into InfluxDB. 

Install InfluxDB Server and Data Source
04:20

Now to install the Telegraf agent and configure the output plugin to save data into the InfluxDB.

Install Telegraf Agent and Configure for InfluxDB
04:28

SNMP stands for Simple Network Management Protocol. 

We can configure Telegraf to read SNMP, save it into InfluxDB and view it in Grafana.

Common devices that support SNMP are routers, switches, printers, servers, workstations and other devices found on IP networks.

Not every network device supports SNMP, or has it enabled, and there is a good chance you don't have an SNMP enabled device available that you can use in this lecture.

So, I will also show you how to install and configure SNMP on your server, as well as read the SNMP data with Telegraf, save it into InfluxDB and view it in Grafana.


Install SNMP Agent and Configure Telegraf SNMP Input
08:00

I will add several more SNMP agents to the Telegraf config.

In order for Telegraf to connect to the external SNMP agents, those other SNMP agents will need to be configured to allow my Telegraf agent on my Grafana server to connect remotely.

At the end of the lecture, I have 3 separate SNMP agents I can query for the next lecture.

Add Multiple SNMP Devices to Telegraf Config
06:43

We Import a SNMP Dashboard that uses the InfluxDB data source and the Telegraf collector.


Import SNMP Dashboard that uses InfluxDB and Telegraf
02:20

In the next few lectures, we will look at how the create and use dashboard variables.

We will manually recreate fully a dynamic dashboard to query our SNMP devices that we've set up in the previous lectures.



Dashboard Variables
06:58

We create a Dynamic Table from a query using our dashboard variables.

Dynamic Table from Variables
04:32

We create Dynamic Singlestats from a query using our dashboard variables.

Preview 02:32

We create Dynamic Graphs from a query using our dashboard variables.

Dynamic Graphs from Variables
03:49
Grafana Questions
5 questions

I want to send alerts using Grafana, but I need to first create an alert notification channel.

In this lecture I will create a new channel for email alerts.

I don't have an SMTP server available, so install a local send only SMTP server on my Grafana server.


$sudo apt install mailutils


At the prompt, I choose Internet Site

After the install is finished, I need to configure the Postfix SMTP server.

$ sudo nano /etc/postfix/main.cf


I edit 2 values at the bottom being,

...

inet_interfaces = loopback-only

inet_protocols = ipv4


Save, and then restart postfix

$ sudo systemctl restart postfix


I can test the SMTP server sends emails using

$ echo "This is the body" | mail -s "This is the subject" -a "FROM:[senders address]" [your personal email]


Next to configure Grafana SMTP settings

$ sudo nano /etc/grafana/grafana.ini


Find the SMTP specific settings, uncomment and edit

[smtp]

enabled = true

host = localhost:25

skip_verify = true

from_address = admin@[your grafana domain name or ip]

from_name = Grafana


Restart Grafana

$ sudo service grafana-server restart


Go back into Grafana, into your new Email notification channel settings and try to send a test email.

Check your SPAM folder.


Create an Email Alert Notification Channel
04:11

We create alerts for when there is no data coming from a SNMP device.

Create Alerts for SNMP No Data
07:06

In this video, I show you how you can create a custom alert channel webhook that sends SMS.
The SMS gateway I will use is AWS SNS.

Create a Custom Webhook Alert Notification Channel for SMS using AWS SNS
08:29

We can also add Telegram to our list of Alerting Notification channels.

To do this install the Telegram app on your phone or PC. It will be easiest to set this up on the PC first.

You will need a BOT API Token and Chat ID.

See Video for example how to do this.

Create Telegram Bot Alert Channel
04:19
Grafana Questions
4 questions

We will look at the logs panel, but we will first need to setup a data source that can read log files.

We will use the Loki Data Source with the Promtail client as the collector on the Grafana Server itself.

Logs Panel
00:31

To keep this as simple as possible, we will install the Loki binary as a service on our existing Grafana server.

Install Loki Binary and Start as a Service
04:07

Now we will create the Promtail service that will act as the collector for Loki.

Install Promtail Binary and Start as a Service
03:49

Now we will install the Loki Data Source, point it to our new Loki Service, and Explore some of the log files on the server.

Install Loki Data Source and Explore
01:48

In this lecture we create a Dashboard with a Graph Panel and a Log Panel, and then we automate the display of annotations by creating an Annotation Query.

Annotation Queries and Linking the Log Panels and Graphs
05:24

Prometheus is already available on the default Ubuntu 18.04 repositories. So we can just install it and it will be set up as a service already.

$ sudo apt install prometheus

$ sudo service prometheus status


Test it by visiting http://[your domain or ip]:9090/graph

Restrict internet access by

$ iptables -A INPUT -p tcp -s localhost --dport 9090 -j ACCEPT

$ iptables -A INPUT -p tcp --dport 9090 -j DROP

$ iptables -L

Preview 03:07
Install Prometheus Node Exporter
07:51
Install Prometheus Dashboard
02:25

Value groups/tags behave very differently depending on the Data Source used for the queries. This example is specific for when using the Zabbix Data Source.

Value Groups/Tags with the Zabbix Data Source
05:52

Value groups/tags behave very differently depending on the Data Source used for the queries. This example is specific for when using the InfluxDB Data Source using Telegraf as the collector.

This example also takes Value groups/tags functionality further by adding a second custom input to the Telegraf collector to help group an existing query that contains no useable information that could already be used for grouping.

Value Groups/Tags with the InfluxDB/Telegraf Data Source
12:18

Through my Zabbix Data Source, I can access many of the properties of my Cisco Switch due to it already being setup as a SNMP device. I quickly create a Dashboard in Grafana for it.

Create a Cisco Switch Dashboard from the Zabbix Data Source
06:09

In this example, my switch is on an internal network and I create a Dashboard using the InfluxDB data source, showing throughput of all it's interfaces,

On my internal network, I created a port forwarding rule to allow the external Telegraf agent, running on my Grafana Server in the cloud, to query SNMP.

The SNMP protocol uses UDP and port 161 by default.

My Switch is a Cisco 2950, connected and working on my internal network.

It has,

  • SNMP enabled,

  • A community named to "external",

  • An ACL set to only allow the IP of my Grafana server for the "external" community,

  • The default gateway set to the IP address of my main network router that also has internet access.

Create a Cisco Switch Dashboard from the InfluxDB/Telegraf Data Source
05:31

I demonstrate creating a disk read/write rates dashboard from the Zabbix data source. This depends on data created from the Template Module Linux Block Devices by Zabbix agent template which is a standard template new on Zabbix 4.4 and is used by the Template OS Linux by Zabbix agent discovery rules.

Disk Read/Write Rates Dashboard with the Zabbix Data Source
09:10