Skip to Main Content
Prometheus: Up & Running
book

Prometheus: Up & Running

by Brian Brazil
July 2018
Beginner to intermediate content levelBeginner to intermediate
386 pages
9h 6m
English
O'Reilly Media, Inc.
Content preview from Prometheus: Up & Running

Chapter 9. Containers and Kubernetes

Container deployments are becoming more common with technologies such as Docker and Kubernetes—you may even already be using them. In this chapter I will cover exporters that you can use with containers, and explain how to use Prometheus with Kubernetes.

All Prometheus components run happily in containers, with the sole exception of the Node exporter as noted in Chapter 7.

cAdvisor

In the same way the Node exporter provides metrics about the machine, cAdvisor is an exporter that provides metrics about cgroups. Cgroups are a Linux kernel isolation feature that are usually used to implement containers on Linux, and are also used by runtime environments such as systemd.

You can run cAdvisor with Docker:

docker run \
  --volume=/:/rootfs:ro \
  --volume=/var/run:/var/run:rw \
  --volume=/sys:/sys:ro \
  --volume=/var/lib/docker/:/var/lib/docker:ro \
  --volume=/dev/disk/:/dev/disk:ro \
  --publish=8080:8080 \
  --detach=true \
  --name=cadvisor \
  google/cadvisor:v0.28.3
Caution

Due to issues with incorrect usage of the Prometheus Go client library, you should avoid versions of cAdvisor before 0.28.3.

If you visit http://localhost:8080/metrics you will see a long list of metrics, as Figure 9-1 shows.

The container metrics are prefixed with container_, and you will notice that they all have an id label. The id labels starting with /docker/ are from Docker and its containers, and if you have /user.slice/ and /system.slice/, they come from systemd running on ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Prometheus: Up & Running, 2nd Edition

Prometheus: Up & Running, 2nd Edition

Julien Pivotto, Brian Brazil
gRPC: Up and Running

gRPC: Up and Running

Kasun Indrasiri, Danesh Kuruppu

Publisher Resources

ISBN: 9781492034131Errata Page