Skip to Content
Prometheus: Up & Running, 2nd Edition
book

Prometheus: Up & Running, 2nd Edition

by Julien Pivotto, Brian Brazil
May 2025
Beginner to intermediate
418 pages
6h 18m
Korean
O'Reilly Media, Inc.
Content preview from Prometheus: Up & Running, 2nd Edition

5장. 레이블

이 작품은 AI를 사용하여 번역되었습니다. 여러분의 피드백과 의견을 환영합니다: translation-feedback@oreilly.com

레이블은 Prometheus의 핵심 부분이며, 강력한 기능 중 하나입니다. 이 장에서는 레이블의 정의, 레이블의 출처 및 자체 지표에 레이블을 추가하는 방법에 대해 알아봅니다.

라벨이란 무엇인가요?

레이블은 시계열과 관련된 키-값 쌍으로, 메트릭 이름과 함께 고유하게 식별합니다. 말이 좀 많으니 예를 들어 보겠습니다.

HTTP 요청에 대한 메트릭이 경로별로 세분화되어 있는 경우 Graphite에서 일반적으로 사용되는 것처럼 메트릭 이름에 경로를 넣어 볼 수 있습니다:1

http_requests_login_total
http_requests_logout_total
http_requests_adduser_total
http_requests_comment_total
http_requests_view_total

이러한 메트릭은 PromQL에서 작업하기 어려울 수 있습니다. 총 요청을 계산하려면 가능한 모든 HTTP 경로를 알고 있거나 모든 메트릭 이름에 대해 잠재적으로 비용이 많이 드는 매칭을 수행해야 합니다. 따라서 이 패턴은 피해야 하는 안티패턴입니다. 대신, 이러한 일반적인 사용 사례를 처리하기 위해 Prometheus에는 레이블이 있습니다. 앞의 경우path 레이블을 사용할 수 있습니다:

http_requests_total{path="/login"}
http_requests_total{path="/logout"}
http_requests_total{path="/adduser"}
http_requests_total{path="/comment"}
http_requests_total{path="/view"}

그런 다음 모든 path 레이블을 하나로 묶어 http_requests_total 메트릭으로 작업할 수 있습니다. PromQL을 사용하면 전체 집계된 요청 비율, 경로 중 하나의 비율 또는 각 요청이 전체에서 차지하는 비율을 얻을 수 있습니다.

레이블이 두 개 이상인 메트릭을 가질 수도 있습니다. 레이블에는 순서가 없으므로 다른 레이블을 무시하고 특정 레이블을 기준으로 집계하거나 여러 레이블을 한꺼번에 집계할 수도 있습니다.

계측 및 대상 레이블

레이블은 계측 레이블과 대상 레이블의 두 가지 소스에서 제공됩니다.PromQL에서 작업할 때는 둘 사이에 차이가 없지만, 레이블을 최대한 활용하려면 이 둘을 구별하는 것이 중요합니다.

계측 레이블은 이름에서 알 수 있듯이 계측에서 비롯되며, 애플리케이션 또는 라이브러리에서 수신하는 HTTP 요청 유형, 데이터베이스와 통신하는 데이터베이스 및 기타 내부 세부 사항 등 애플리케이션 또는 라이브러리 내부에서 알려진 사항에 관한 것입니다.

대상 레이블은 특정 모니터링 대상, 즉 Prometheus가 스크랩하는 대상을 식별합니다. 대상 레이블은 아키텍처와 더 관련이 있으며, 어떤 애플리케이션인지, 어떤 데이터센터에 있는지, 개발 또는 프로덕션 환경에 있는지, ...

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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Prometheus: Up & Running, 2nd Edition

Prometheus: Up & Running, 2nd Edition

Julien Pivotto, Brian Brazil
Mastering Prometheus

Mastering Prometheus

William Hegedus
Argo CD: Up and Running

Argo CD: Up and Running

Andrew Block, Christian Hernandez
Kubernetes: Up and Running, 3rd Edition

Kubernetes: Up and Running, 3rd Edition

Brendan Burns, Joe Beda, Kelsey Hightower, Lachlan Evenson

Publisher Resources

ISBN: 9798341654181