Ronald McCollam
Getting Started with Grafana
Real-Time Dashboards for IT and Business Operations
The Apress logo.
Ronald McCollam
Somerville, MA, USA
ISBN 978-1-4842-8308-0 e-ISBN 978-1-4842-8309-7
https://doi.org/10.1007/978-1-4842-8309-7
Ronald McCollam 2022
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
This Apress imprint is published by the registered company APress Media, LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY 10004, U.S.A.
To my partner, my friends, and family (both birth and chosen), who put up with my absence for far too many evenings and weekends. Thank you!
Introduction
The first time I saw Grafana I fell in love.
When I started monitoring IT operations at a legal document analysis company 20 years ago, there werent a lot of good options for simply visualizing what was really going on. There were plenty of tools to capture data from the bulky, noisy racks of hardware in the datacenter, but they were all limited to showing simple statistics in tables or (in the case of the really fancy ones) line graphs that could plot a single set of metrics over time. Monitoring meant staring at these tables and charts at least a few times per week to look for indications of trends that might become problems down the line. Automated alerts were simple thresholds for CPU or memory utilization that pointlessly woke me up at 3:00 in the morning, but still had to be checked and reset before I could go back to bed. I spent as much time trying to build ways to see and manage my data as I did in actually using it productively.
Weve come a long way in the last couple of decades. Most services now run in cloud environments where individual servers no longer matter. At the same time, the move to microservice architectures means that the number of services that an operator or Site Reliability Engineer (SRE) cares about has exploded. The simple tools from my datacenter days are still there, but their singular focus cant give the broader context that we now need to understand how these complex components interrelate.
Thats where Grafana comes in. Grafana is the gold standard for live, real-time data visualization. It works with your existing tools and talks to your data where it lives. Rather than ingesting static point-in-time CSV dumps, Grafana runs queries against databases or services. Forget exporting and importing, no need to copy or move data; Grafana sits on top of your existing infrastructure and just lets you see.
You might be a manager who needs to meet specific service-level objectives (SLOs) for your business, wondering how best to track the service-level indicators (SLIs) that tell you if youre meeting your goals. Perhaps, youve just read the Google SRE Handbook and want a good way to track the Four Golden Signals for your application. Or maybe you just care about data and want a beautiful, easy way to visualize it! This is the book to get you started.
Youll first learn how to get up and running with Grafana in the cloud and how to create simple dashboards. From there, youll deploy Grafana in your own environment, connect it to your own data, and manage user access and permissions to that data.
Next, youll see how to design beautiful and effective dashboards that show your data in the most meaningful way. Youll learn how to build powerful workflows that guide people to the most relevant information, even when that information is scattered across many tools and storage systems. Templates and variables will let you create comprehensive views of data with minimal effort, and alerts will warn you about problems that occur when youre busy elsewhere.
Finally, youll explore the full power and extensibility of Grafana. Youll see how to scale Grafana and treat its configuration and dashboards as code. Youll use the Grafana API to automate processes and provision new environments. Youll even get a peek at some of the enhancements available in the Enterprise version of Grafana.
As monitoring has grown to observability, weve moved from looking at simple metrics from a single program or server to thinking about systems. A high CPU utilization doesnt matter as long as transactions are being processed within the businesss SLOs. A server going offline entirely is fine if the service heals itself and keeps running. I might care to know that it happened, but I certainly dont want it to wake me up in the middle of the night!
Grafana is everything that I wanted when I was (literally) keeping the lights on in a datacenter decades ago. It elegantly combines data from nearly any source into a simple and beautiful interface that can give both real-time views and historical context about anything you care to track. After discovering it, I threw away all of my home-built scripts and clunky tables and charts and have never looked back.
In this book, I hope to give you an introduction to the power that Grafana contains. The concepts and techniques covered here will enable you to build meaningful representations of your data that can be used to inform decisions about scaling, point out potential issues, and even show how seemingly separate systems interrelate.
Grafana is an amazing tool that can be used almost anywhere. I hope you will enjoy it as much as I do!
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub.
Acknowledgments
Writing a book turns out to be a lot of work. Thats something that everyone says, so I was prepared going into this to put my head down for as long as it took. What I wasnt prepared for was the impact it would have on everyone around me.
To the team at Apress, your help and advice has been fantastic. Jonathan Gennick, for kicking off the process and helping me understand just what is needed; Jill Balzano, for cat herding and keeping on top of the process; and especially Alfons Muoz, for reviewing every piece of technical instruction and checking that every step worked and every screenshot was clear. (If I had realized how tough your job was, I might have left out the installation instructions for the Raspberry Pi at least!)