Reader small image

You're reading from  Hands-On Infrastructure Monitoring with Prometheus

Product typeBook
Published inMay 2019
PublisherPackt
ISBN-139781789612349
Edition1st Edition
Right arrow
Authors (2):
Joel Bastos
Joel Bastos
author image
Joel Bastos

Joel Bastos is an open source supporter and contributor, with a background in infrastructure security and automation. He is always striving for the standardization of processes, code maintainability, and code reusability. He has defined, led, and implemented critical, highly available, and fault-tolerant enterprise and web-scale infrastructures in several organizations, with Prometheus as the cornerstone. He has worked at two unicorn companies in Portugal and at one of the largest transaction-oriented gaming companies in the world. Previously, he has supported several governmental entities with projects such as the Public Key Infrastructure for the Portuguese citizen card. You can find his blogs at kintoandar and on Twitter with the handle @kintoandar.
Read more about Joel Bastos

Pedro Araújo
Pedro Araújo
author image
Pedro Araújo

Pedro Arajo is a site reliability and automation engineer and has defined and implemented several standards for monitoring at scale. His contributions have been fundamental in connecting development teams to infrastructure. He is highly knowledgeable about infrastructure, but his passion is in the automation and management of large-scale, highly-transactional systems. Pedro has contributed to several open source projects, such as Riemann, OpenTSDB, Sensu, Prometheus, and Thanos. You can find him on Twitter with the handle @phcrva.
Read more about Pedro Araújo

View More author details
Right arrow

Prometheus Metrics Fundamentals

Metrics are the core resources that the Prometheus stack ingests to provide you with useful information. Understanding them correctly is essential to fully utilize, manage, or even extend the realm of possibilities this stack has to offer. From data to information, and finally to knowledge, metrics are here to help you.

In brief, the following topics will be covered in this chapter:

  • Understanding the Prometheus data model
  • A tour of the four core metric types
  • Longitudinal and cross-sectional aggregations

Understanding the Prometheus data model

To understand the Prometheus data model, we need to go through what makes a time series and the storage of such data. These concepts will be invaluable throughout this book.

Time series data

Time series data can usually be defined as a sequence of numerical data points that are indexed chronologically from the same source. In the scope of Prometheus, these data points are collected at a fixed time interval. As such, this kind of data, when represented in graphical form, will most commonly plot the evolution of the data through time, with the x axis being time and the y axis being the data value.

...

A tour of the four core metric types

Prometheus metrics are divided into four main types: counters, gauges, histograms, and summaries. It is essential to understand them in depth, as most functions provided by Prometheus only work correctly with a given data type. So, to that end, here is an overview of each.

Counter

This is a strictly cumulative metric whose value can only increase. The only exception for this rule is when the metric is reset, which brings it back to zero.

This is one of the most useful metric types because even if a scrape fails, you won't lose the cumulative increase in the data, which will be available on the next scrape. To be clear, in the case of a failed scrape, granularity would be lost as fewer...

Longitudinal and cross-sectional aggregations

The last concept to grasp when thinking about time series is how aggregations work on an abstract level. One of Prometheus' core strengths is that it makes the manipulation of time series data easy, and this slicing and dicing of data usually boils down to two kinds of aggregations, which are often used together: longitudinal and cross-sectional aggregations.

In the context of time series, an aggregation is a process that reduces or summarizes the raw data, which is to say that it receives a set of data points as input and produces a smaller set (often a single element) as output. Some of the most common aggregation functions in time series databases are minimum, maximum, average, count, and sum.

To better understand how these aggregations work, let's look at some data using the example time series we presented earlier in...

Summary

In this chapter, we came to understand what time series data is, and looked at an overview of how a modern time series database such as Prometheus works, not only logically, but physically as well. We went through the Prometheus metrics notation and how metric names and labels relate to each other, and also covered what defines a sample. Prometheus metrics have four types, and we had the chance to go through every one of them and provide some useful examples. Finally, we dived into how longitudinal and cross-sectional aggregations work, which is essential to fully take advantage of Prometheus' query language.

In the next chapter, we'll return to a more hands-on approach and go into Prometheus server configuration, and how to manage it on both virtual machines and Kubernetes.

Questions

  1. What is the mandatory requirement of any graphical time series representation?
  2. What are the components for a data point to be considered as time series data?
  3. When a Prometheus server crashes, what prevents it from losing data?
  4. What is the Prometheus in-memory database time window for storing data?
  5. What are the components of a Prometheus sample?
  6. What are the common use cases for both histograms and summaries?
  7. What is the difference between a cross-sectional and a longitudinal aggregation?

Further reading

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Hands-On Infrastructure Monitoring with Prometheus
Published in: May 2019Publisher: PacktISBN-13: 9781789612349
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 AU $19.99/month. Cancel anytime

Authors (2)

author image
Joel Bastos

Joel Bastos is an open source supporter and contributor, with a background in infrastructure security and automation. He is always striving for the standardization of processes, code maintainability, and code reusability. He has defined, led, and implemented critical, highly available, and fault-tolerant enterprise and web-scale infrastructures in several organizations, with Prometheus as the cornerstone. He has worked at two unicorn companies in Portugal and at one of the largest transaction-oriented gaming companies in the world. Previously, he has supported several governmental entities with projects such as the Public Key Infrastructure for the Portuguese citizen card. You can find his blogs at kintoandar and on Twitter with the handle @kintoandar.
Read more about Joel Bastos

author image
Pedro Araújo

Pedro Arajo is a site reliability and automation engineer and has defined and implemented several standards for monitoring at scale. His contributions have been fundamental in connecting development teams to infrastructure. He is highly knowledgeable about infrastructure, but his passion is in the automation and management of large-scale, highly-transactional systems. Pedro has contributed to several open source projects, such as Riemann, OpenTSDB, Sensu, Prometheus, and Thanos. You can find him on Twitter with the handle @phcrva.
Read more about Pedro Araújo