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 4. Exposition

In Chapter 3 I mainly focused on adding instrumentation to your code. But all the instrumentation in the world isn’t much use if the metrics produced don’t end up in your monitoring system. The process of making metrics available to Prometheus is known as exposition.

Exposition to Prometheus is done over HTTP. Usually you expose metrics under the /metrics path, and the request is handled for you by a client library. Prometheus uses a human-readable text format, so you also have the option of producing the exposition format by hand. You may choose to do this if there is no suitable library for your language, but it is recommended you use a library as it’ll get all the little details like escaping correct.

Exposition is typically done either in your main function or another top-level function and only needs to be configured once per application.

Metrics are usually registered with the default registry when you define them. If one of the libraries you are depending on has Prometheus instrumentation, the metrics will be in the default registry and you will gain the benefit of that additional instrumentation without having to do anything. Some users prefer to explicitly pass a registry all the way down from the main function, so you’d have to rely on every library between your application’s main function and the Prometheus instrumentation being aware of the instrumentation. This presumes that every library in the dependency chain cares about instrumentation ...

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