Reader small image

You're reading from  Mastering Prometheus

Product typeBook
Published inApr 2024
PublisherPackt
ISBN-139781805125662
Edition1st Edition
Concepts
Right arrow
Author (1)
William Hegedus
William Hegedus
author image
William Hegedus

William Hegedus has worked in tech for over a decade in a variety of roles, culminating in site reliability engineering. He developed a keen interest in Prometheus and observability technologies during his time managing a 24/7 NOC environment and eventually became the first SRE at Linode, one of the foremost independent cloud providers. Linode was acquired by Akamai Technologies in 2022, and now Will manages a team of SREs focused on building the internal observability platform for Akamai's Connected Cloud. His team is responsible for a global fleet of Prometheus servers spanning over two dozen data centers and ingesting millions of data points every second, in addition to operating a suite of other observability tools. Will is an open source advocate and contributor who has contributed code to Prometheus, Thanos, and many other CNCF projects related to Kubernetes and observability. He lives in central Virginia with his wonderful wife, four kids, three cats, two dogs, and a bearded dragon.
Read more about William Hegedus

Right arrow

Enabling Systems Monitoring with the Node Exporter

Now that we’re all experts on running Prometheus itself, it’s time to get into what truly sets Prometheus apart: the ecosystem around it. Prometheus has a vibrant community with a multitude of open source projects that extend it and expose data to it. Many Prometheus-related projects are exporters.

The term “exporter” in Prometheus refers to any application that runs independently to expose metrics from some other data source that is not exposing Prometheus metrics natively. There are exporters for almost anything you can think of, from MySQL to Minecraft, and a non-exhaustive list can be found on Prometheus’s official docs site at https://prometheus.io/docs/instrumenting/exporters/. However, in this chapter, we’re going to focus on the most popular and common exporter: the Node Exporter.

We’re going to cover the following main topics:

  • Node Exporter overview
  • Default...

Technical requirements

For this chapter, you can connect to the Prometheus cluster we created in Chapter 2 to follow along with exploring metrics, but the only true requirement for this chapter is optional. It is only needed if you want to experiment with the basics of writing a Prometheus exporter:

Code used in this chapter is available at https://github.com/PacktPublishing/Mastering-Prometheus.

Note

This chapter focuses only on the Node Exporter, which is only useful for systems with *NIX kernels (e.g., Linux, FreeBSD, MacOS, etc.). For Windows systems, a similar – but separate – exporter exists called the Windows Exporter (https://github.com/prometheus-community/windows_exporter).

Node Exporter overview

The Node Exporter is one of the select few exporters maintained by the official Prometheus project, alongside others such as the Blackbox Exporter and the SNMP Exporter. Its purpose is to expose a variety of machine-level metrics pertaining to resources such as CPU, disk, memory, networking, and more.

One of the things I often say to people asking whether we have some system-level metric in Prometheus is, “If it’s in /proc, the Node Exporter can get it.”

What’s /proc?

In Linux systems, a /proc directory exists that contains a plethora of information about the state of the machine. The Linux kernel documentation describes it thusly:

The proc file system acts as an interface to internal data structures in the kernel. It can be used to obtain information about the system and to change certain kernel parameters at runtime (sysctl).

The Node Exporter primarily retrieves data through the /proc pseudo-filesystem. There are...

Default collectors

At the time of writing, there are a whopping 49 different collectors that are enabled by default in the Node Exporter. Many of them are either niche (such as dmi) or dependent on your infrastructure (such as filesystem collectors for xfs and zfs). Rather than go through all of them, we’ll take a look at some of the most useful ones to see what info they provide and why you would care about it.

conntrack

The conntrack collector exposes metrics related to the Linux kernel’s netfilter connection tracking subsystem. This is used to keep track of connections established to your server and can cause issues when the table it uses becomes full.

Two commonly used metrics from this collector are as follows:

...

The textfile collector

The textfile collector is a hidden gem in the Node Exporter. This single collector adds tremendous versatility to what you can accomplish with a Prometheus monitoring stack.

Using the textfile collector, you can read Prometheus-formatted metrics from files on the server and include them in the output of the Node Exporter’s /metrics scrape endpoint.

Being able to read metrics from a file opens up a whole new world of monitoring short-lived processes such as batch or cron jobs, where it isn’t possible or doesn’t make sense to expose metrics on an HTTP endpoint for Prometheus to scrape. For example, at my company, we leverage the textfile collector to expose metrics related to the last time a server executed its scheduled synchronization with our configuration management system.

The textfile collector is enabled by default but requires additional configuration to actually work. For the collector to work, it must know where it should...

Troubleshooting the Node Exporter

I would be remiss if I gave you the impression that the Node Exporter just magically works 100% of the time. Undoubtedly, you’ll experience issues where Node Exporter scrapes begin experiencing issues such as slow scrapes or even timeouts. Thankfully, the Node Exporter provides us with some per-collector metrics to help pinpoint where the issue lies.

The node_scrape_collector_success metric returns whether or not running an individual collector was successful. But wait – before you go putting alerts in for any time any node_scrape_collector_success time series returns a 0, remember that not all of the collectors that are enabled by default are expected to apply to your system. For example, I seriously doubt your server has both InfiniBand and Fibre Channel connections (most likely you have neither), so something’s always going to be marked as failing.

Instead, the metric I tend to look at the most for Node Exporter troubleshooting...

Summary

In this chapter, we learned all about Prometheus’s most popular exporter, the Node Exporter. We went over the basics of what an exporter is and what is involved in creating one. Then, we dove headfirst into the dozens of collectors that the Node Exporter enables by default. Finally, we looked at how to use the textfile collector and how to troubleshoot issues with the Node Exporter.

In our next chapter, we’re going to be stepping out of the realm of “vanilla” Prometheus and begin looking at how we can extend and augment Prometheus through the use of other open source projects. To begin, we’ll see how projects such as VictoriaMetrics and Grafana Mimir can function as remote storage for Prometheus metrics.

Further reading

To learn more about the topics that were covered in this chapter, take a look at the following resources:

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Mastering Prometheus
Published in: Apr 2024Publisher: PacktISBN-13: 9781805125662
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
William Hegedus

William Hegedus has worked in tech for over a decade in a variety of roles, culminating in site reliability engineering. He developed a keen interest in Prometheus and observability technologies during his time managing a 24/7 NOC environment and eventually became the first SRE at Linode, one of the foremost independent cloud providers. Linode was acquired by Akamai Technologies in 2022, and now Will manages a team of SREs focused on building the internal observability platform for Akamai's Connected Cloud. His team is responsible for a global fleet of Prometheus servers spanning over two dozen data centers and ingesting millions of data points every second, in addition to operating a suite of other observability tools. Will is an open source advocate and contributor who has contributed code to Prometheus, Thanos, and many other CNCF projects related to Kubernetes and observability. He lives in central Virginia with his wonderful wife, four kids, three cats, two dogs, and a bearded dragon.
Read more about William Hegedus

Metric

Description

node_nf_conntrack_entries

Current number of entries in the connection tracking table