Book Image

Building IoT Visualizations using Grafana

By : Rodrigo Juan Hernández
5 (1)
Book Image

Building IoT Visualizations using Grafana

5 (1)
By: Rodrigo Juan Hernández

Overview of this book

Grafana is a powerful open source software that helps you to visualize and analyze data gathered from various sources. It allows you to share valuable information through unclouded dashboards, run analytics, and send notifications. Building IoT Visualizations Using Grafana offers how-to procedures, useful resources, and advice that will help you to implement IoT solutions with confidence. You’ll begin by installing and configuring Grafana according to your needs. Next, you’ll acquire the skills needed to implement your own IoT system using communication brokers, databases, and metric management systems, as well as integrate everything with Grafana. You’ll learn to collect data from IoT devices and store it in databases, as well as discover how to connect databases to Grafana, make queries, and build insightful dashboards. Finally, the book will help you implement analytics for visualizing data, performing automation, and delivering notifications. By the end of this Grafana book, you’ll be able to build insightful dashboards, perform analytics, and deliver notifications that apply to IoT and IT systems.
Table of Contents (21 chapters)
1
Part 1: Meeting Grafana
4
Part 2: Collecting Data from IoT Devices
8
Part 3: Connecting Data Sources and Building Dashboards
12
Part 4: Performing Analytics and Notifications
15
Part 5: Integrating Grafana with Other Platforms

Installing Grafana on Ubuntu Server

Ubuntu is one of the most popular operating systems for servers, so we will learn how to install Grafana on it.

Installing Grafana on Ubuntu is a very straightforward procedure because there are Ubuntu packages.

Installation instructions

Let’s look at what we need to do here:

  1. As before, we first run updates:
    $ sudo apt-get update 
    $ sudo apt-get upgrade
  2. Next, if you do not have wget installed on your server, you can install it as follows:
    $ sudo apt-get install apt-transport-https
    $ sudo apt-get install software-properties-common wget
  3. Then you can use wget to download the GPG key and add it to the APT keys. In this way, you authorize Grafana packages to be installed on the system:
    $ wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add –
  4. After that, you can add the Grafana repository (stable release) to the APT source list:
    $ echo "deb https://packages.grafana.com/oss/deb stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
  5. Finally, run the following commands:
    $ sudo apt-get update
    $ sudo apt-get install grafana

Now that you have installed Grafana on Ubuntu Server, let’s see how to run it.

Running Grafana on Ubuntu Server

There are two ways of running Grafana as a service. Let’s have a look at them.

Running Grafana using systemd

Grafana services can be managed by systemd.

To start Grafana, simply execute the following:

$ sudo systemctl start grafana-server

To see the Grafana service status, run this command:

$ sudo systemctl status grafana-server

To stop the service, use this command:

$ sudo systemctl stop grafana-server

And to enable start at boot, use this command:

$ sudo systemctl enable grafana-server.service

Now that you know how to do it with systemd, let’s see how to do it with initd.

Running Grafana with initd

You can run Grafana as follows:

$ sudo service grafana-server start

To stop Grafana, use this command:

$ sudo service grafana-server stop

To get the service status, run this command:

$ sudo service grafana-server status

To configure it to start at boot, use the following command:

$ sudo update-rc.d grafana-server defaults

You have now installed and executed Grafana on Ubuntu Server. You also configured it to start on boot. Now let’s see how to access Grafana from a browser.

Accessing Grafana

Before trying to access Grafana, make sure that the service is running. You can check it using the preceding commands. If it is stopped, you must start it as shown earlier.

As soon as you have Grafana installed and running, you can access it by pointing the browser to http://your-server-ip-or-name:3000.

The default credentials are admin/admin.

Now that you have learned how to install and run Grafana on Ubuntu Server as well as how to manage start-up at boot using two different methods, let’s move on to the next section, where you will learn how to deploy Grafana using Docker.