Reader small image

You're reading from  Building IoT Visualizations using Grafana

Product typeBook
Published inJul 2022
PublisherPackt
ISBN-139781803236124
Edition1st Edition
Right arrow
Author (1)
Rodrigo Juan Hernández
Rodrigo Juan Hernández
author image
Rodrigo Juan Hernández

Rodrigo Juan Hernández is an electronic engineer passionate about IoT even before it existed. He has been working on tech for more than 18 years until now. For several years he has been focusing on the IoT ecosystem. He is currently giving consultation about IoT systems to clients around the world. He also produces content online about IoT and related subjects and the content is available on his blog, Youtube channel, and social networks - mainly LinkedIn. He also writes for companies that need good quality content about their products and services. His main objective nowadays is helping others to understand and implement IoT solutions.
Read more about Rodrigo Juan Hernández

Right arrow

Chapter 6: Getting Data and Building Dashboards

In the previous chapters, you have learned about data sources, SQL and NoSQL databases, and time-series databases.

In this chapter, you will see how you can use these data sources for feeding data into Grafana and building impressive dashboards.

Grafana offers a variety of panels for representing different types of data. In this chapter, you will learn how to perform data visualization using several of these panels.

In particular, you will learn about the following:

  • Getting data from time-series databases
  • Showing time-series data in graph panels
  • Building table data panels
  • How to show categorical data
  • Showing text data
  • Building a georeferenced map
  • How to make a heatmap

This is a highly practical chapter, where you will be able to build dashboards from scratch. While the previous chapters prepared the terrain for the installation, administration, and managing of data, this chapter goes directly...

Getting data from time-series databases

In Chapter 4, Data Sources for Grafana, you learned about the concepts related to this type of database. You have seen two open source projects – InfluxDB and OpenTSDB.

In this chapter, all the operations are performed on an InfluxDB database. In the following screenshot, you can see the basic parameters (delimited by red squares) that you have to ingress for accessing an InfluxDB database from Grafana.

Any other additional configuration is related to a particular implementation of InfluxDB, such as Transport Layer Security (TLS) settings, timeouts, or custom HTTP headers. So, you will have to adapt the configuration of the InfluxDB data source to your particular installation.

Naturally, it’s always a good idea to use secure connections, so TLS encryption is a must in production systems.

You can see the configuration settings page of the InfluxDB data source in the following screenshot:

Figure 6...

Showing time-series data in graph panels

Showing time-series graphs is possibly the main objective of any Grafana implementation. Using this type of graph not only allows you to see a clear picture of the evolution of some variables but also gives you the option of performing analytics on the data.

In this section, you will learn how to create your first graph panel using a time-series data source. So, let’s start with the dashboard creation, as you can see in the following screenshot:

Figure 6.4 – The creation of a dashboard

To create a dashboard, you have to go to the plus sign in the left menu and click on Dashboard. A new, empty dashboard will be created.

From here, you will have to create panels, where you will be able to specify the type of visualization that you need. So, click on Add an empty panel to explore the available options. You will get a view similar to the one shown in the following screenshot:

Figure...

Building table data panels

Time-series panels are an excellent tool for showing time-series data, but sometimes, it can be useful to use table data panels.

The table data panel allows you to show data in a table, ordered by time. In the following figure, you can see an example of one of these panels:

Figure 6.10 – A table data panel

The table panel comes with the basic installation of Grafana, and you can select it in the visualization menu.

Table panel options

Besides the common panel options, the table panel offers a few more customization settings. Let’s look at them.

Table options

These configuration settings have the following options:

  • Show headers: This allows you to show or hide the names imported from the data source.
  • Column width: Here, you can specify the column width in pixels. By default, Grafana calculates it based on the table size and the minimum column width. The minimum column width by default is 150...

How to show categorical data

Sometimes, you need to know whether a pump is working or not, or if a light is on or off.

On the other hand, sometimes, it is useful to perform the classification of some data. Think about the number of times that each IoT device sent data, or the number of devices that have a specific version of the firmware.

In this section, you will learn how to build visualizations of categorical data.

Using stat panels

When you want to show the state of a thing, a machine, a process, and so on, you can use a stat panel. This panel allows you to show any number or text associated with the state that you want to show.

For instance, you can show whether the power mains of an Uninterruptable Power Supply (UPS) is present or not, or whether its batteries are okay or need to be replaced.

You can convert numerical data to categorical data, performing a mapping between data values and categories. For example, you can map a low level of liquid in a tank with...

Building a georeferenced map

Showing assets, persons, animals, or vehicles on a map is a common use of IoT. In this section, you will see how to build georeferenced maps using Grafana.

The Geomap panel

The best option for showing georeferenced data in Grafana is Geomap. This plugin comes installed by default, so you will only have to configure it. Let’s see the configuration options.

Map view

This setting allows you to specify the starting coordinates and zoom of the panel. You can choose from preloaded regions or write down coordinates. You can see an example in the following screenshot:

Figure 6.18 – A map view of Geomap

Let’s see how you can configure the base layer.

The base layer

This panel offers several base layers for showing world maps. By default, Grafana loads the CartoDB base map.

Each of the base maps brings specific options to change the style of the map. You can define base layers in the .ini configuration...

Histograms and heatmaps

In this section, we will explore two visualization panels – Histograms and Heatmaps. Let’s start with histograms.

The Histogram panel

You can use histograms to represent the distribution of numerical data. In a histogram, the data points are grouped into buckets (like discretized intervals) and then counted.

So, for each X-axis bucket, the count of data points is displayed on the Y axis. You can use time series or table data with numerical fields.

Display options

Let´s see the options of the Histogram panel. They allow us to set how we group, calculate, and show the data.

  • Bucket size

This option lets you specify the size of the bucket. If you leave it empty, the bucket size will be approximately 10 percent of the full range of the data.

  • Bucket offset

You can set a value here between 0 and the bucket size for shifting the aggregation window. In general, you will use this option when you specify the...

Summary

In this chapter, you have learned how to build several types of dashboards using different panels. You have learned how you can customize each of these panels and adapt them to your needs.

The panels presented in this chapter are tailored for use with different types of data – time-series, categorical, text, georeferenced, and statistical. With all this information, you can now build any type of dashboard for your IoT projects.

In the next chapter, we will see how to install and manage plugins in Grafana.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Building IoT Visualizations using Grafana
Published in: Jul 2022Publisher: PacktISBN-13: 9781803236124
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Rodrigo Juan Hernández

Rodrigo Juan Hernández is an electronic engineer passionate about IoT even before it existed. He has been working on tech for more than 18 years until now. For several years he has been focusing on the IoT ecosystem. He is currently giving consultation about IoT systems to clients around the world. He also produces content online about IoT and related subjects and the content is available on his blog, Youtube channel, and social networks - mainly LinkedIn. He also writes for companies that need good quality content about their products and services. His main objective nowadays is helping others to understand and implement IoT solutions.
Read more about Rodrigo Juan Hernández