Reader small image

You're reading from  Learn Grafana 7.0

Product typeBook
Published inJun 2020
PublisherPackt
ISBN-139781838826581
Edition1st Edition
Tools
Right arrow
Author (1)
Eric Salituro
Eric Salituro
author image
Eric Salituro

Eric Salituro is currently a Software Engineering Manger with the Enterprise Data and Analytics Platform team at Zendesk. He has an IT career spanning over 30 years, over 20 of which were in the motion picture industry working as a pipeline technical director and software developer for innovative and creative studios like DreamWorks, Digital Domain, and Pixar. Before moving to Zendesk, he worked at Pixar helping to manage and maintain their production render farm as a Senior Software Developer. Among his accomplishments there was the development of a Python API toolkit for Grafana aimed at streamlining the creation of rendering metrics dashboards
Read more about Eric Salituro

Right arrow
Working with Advanced Dashboard Features

By now, you're probably feeling pretty comfortable with Grafana but have legitimate concerns about the effort involved. You may be thinking that the possibility of writing a lot of code to handle ETL tasks might eat into your time budget for building the dashboards. Perhaps the number of panels you will have to configure and organize on multiple dashboards seems potentially tedious, error-prone work.

In this chapter, we're going to look at how to reduce the ETL burden using off-the-shelf tools, as well as how to use templates to fill a dashboard with variants using only a single panel. We'll also show you how annotations make it possible to drill down into aggregated data in order to examine individual data points. Then, we'll take our dashboards and link them together with simple UI elements. Finally, we'll look at strategies for sharing our dashboards...

Technical requirements

Building the data server

Imagine for a moment that you are working for the public works department of a major city. Throughout the day, citizens use their phones and computers to report problems via the 311 service (https://www.open311.org/). You've been tasked with accessing the 311 data, building dashboards, and presenting them to various stakeholders within the city government. They will want to see how many of the various types of calls are made to the system, as well as how they are distributed across the city in various council districts.

Before we can build our dashboards, we'll need to get some data. Luckily, many major cities make anonymized 311 data publicly accessible in many popular data formats, including JSON and CSV. For this exercise, we'll be working with 311 data from the city of San Francisco. This data is available via their extensive data portal at https://data.sfgov.org/City-Infrastructure/Current-FY-Cases/iy63-pi3t.

To get...

Templating dashboards

Once you've loaded the data into Elasticsearch, open up Grafana and create a new Elasticsearch data source using these options:

  • Name: Elasticsearch (or whatever you prefer)
  • HTTP/URL: http://elasticsearch:9200
  • HTTP/Access: Server (default)
  • Elasticsearchdetails/Indexname: data-index
  • Elasticsearchdetails/pattern: No pattern
  • Elasticsearchdetails/Timefieldname: Opened
  • Elasticsearchdetails/Version: 7.0+
  • Elasticsearchdetails/Mintimeinterval: 5m

The data source page should look something like this:

You may have noticed that while we have typically been using localhost to access servers such as Grafana and InfluxDB, we're using elasticsearch in this particular case. By default, Elasticsearch is not configured to allow Cross-Origin Resource Requests (CORS) that would be originated from a data...

Linking dashboards

Now that you have your dashboards set up, you may have noticed that navigating between dashboards can be a bit tedious. To go to a different dashboard, you click the dashboard's name, click the Grafana logo, or click the Dashboards sidebar menu, and then you look for your dashboard and click on it. This isn't very efficient and makes it difficult to deploy your dashboards as a coherent site that doesn't force your users to go rummaging through a lot of dashboards that aren't relevant to them in search of the ones that are.

Fortunately, you're in luck! Grafana provides a simple, dashboard-level linking system for facilitating the creation of navigable dashboards. Dashboard linking supports intra-dashboard links via tagging, or inter-dashboard via URL. Let's see how that works for our newly created dashboards.

Adding dashboard tags

The first step will be to make a copy of the dashboard you created in the previous...

Annotating dashboards

Annotations are a versatile mechanism for providing highlighting individual events in the time series. By singling out a single data point at a particular time and marking it with metadata, you have the capability to mark up your dashboard panels with rich data such as text and tagging. Grafana provides two annotation capabilities to choose from: native Grafana annotations are created interactively and stored with the dashboard on the Grafana server, and data source annotations are created as queries to the data source, with the query and annotation configuration stored with the dashboard.

Annotating the graph panel

Since data source annotations can be resource-intensive, we'll demonstrate annotating with a single-panel dashboard. Create a new dashboard and a single Graph panel with the following settings:

  • Query/Data Source: Elasticsearch
  • Query/Query: RequestType:Graffiti
  • Panel...

Sharing dashboards

Now that you've created these lovely dashboards, how do you share them with the world (or your boss)? One of the first questions you must consider is the link between your dashboards and your data sources. For the sake of this book, we'll keep the data sources and the dashboards in close proximity, that is, on the same host and the same network. If you wish to share your dashboards, they will need to access your machine and possibly your network. You'll want to give some serious thought to how best to share them. Here, we'll discuss a few strategies and their pros and cons.

Sharing dashboard links

The most straightforward sharing mechanism is to simply give out a URL to your Grafana server that references the dashboard in question. Click the Share dashboard button (the box with an arrow coming out of it) and use the Link tab to create a link. If you want the dashboard to preserve the current view, make sure you enable Current...

Summary

We've accomplished a lot in this chapter. Here, we created an Elasticsearch server and imported a realistic textual dataset with Logstash and learned about several different types of template variables, as well as how to set them up to parameterize our dashboards. Then, we applied template variables to repeat rows and panels and discovered the native annotation feature, as well as how to create annotations from an Elasticsearch query. Finally, we explored different sharing options and their pros and cons.

At this point, you have been exposed to enough of Grafana to now go off and create dashboards built around your own data sources. We've looked at two of the more popular data sources, InfluxDB and Elasticsearch, but we've only scratched the surface of their capabilities, apart from being used with Grafana. I encourage you to explore them; the more you understand how data sources manage data, the better you will be able to tailor your datasets to...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Learn Grafana 7.0
Published in: Jun 2020Publisher: PacktISBN-13: 9781838826581
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
Eric Salituro

Eric Salituro is currently a Software Engineering Manger with the Enterprise Data and Analytics Platform team at Zendesk. He has an IT career spanning over 30 years, over 20 of which were in the motion picture industry working as a pipeline technical director and software developer for innovative and creative studios like DreamWorks, Digital Domain, and Pixar. Before moving to Zendesk, he worked at Pixar helping to manage and maintain their production render farm as a Senior Software Developer. Among his accomplishments there was the development of a Python API toolkit for Grafana aimed at streamlining the creation of rendering metrics dashboards
Read more about Eric Salituro