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

17장. 기록 규칙

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

HTTP API만이 PromQL에 액세스할 수 있는 유일한 방법은 아닙니다. 기록 규칙을 사용하여 Prometheus가 PromQL 표현식을 정기적으로 평가하고 그 결과를 수집하도록 할 수도 있습니다. 이는 대시보드 속도를 높이고, 다른 곳에서 사용할 수 있도록 집계된 결과를 제공하고, 범위 벡터 함수를 구성하는 데 유용합니다. 다른 모니터링 시스템에서는 이와 동등한 기능의 스탠딩 쿼리 또는 연속 쿼리를 호출할 수 있습니다. 알림 규칙( 18장에서 다룸)도 기록 규칙의 변형입니다. 이 장에서는 언제 어떻게 기록 규칙을 사용하는지에 대해 설명합니다.

레코딩 규칙 사용

레코딩 규칙은 prometheus.yml과 별도의 파일에 저장되며, 이를 규칙 파일이라고 합니다. prometheus.yml과 마찬가지로 규칙 파일도 YAML 형식을 사용합니다. prometheus.yml의rule_files 최상위 필드를 사용하여 규칙 파일의 위치를 지정할 수 있습니다. 예를 들어예제 17-1은 두 개의 대상을 스크래핑하는 것 외에도 rules.yml이라는 규칙 파일을 로드합니다.

예 17-1. 두 개의 대상을 스크래핑하고 규칙 파일을 로드하는prometheus.yml
global:
  scrape_interval: 10s
  evaluation_interval: 10s
rule_files:
 - rules.yml
scrape_configs:
 - job_name: prometheus
   static_configs:
    - targets:
      - localhost:9090
 - job_name: node
   static_configs:
    - targets:
      - localhost:9100

file_sd_configs 의 필드와 유사하게 는 filesrule_files "파일"에서 다룬 대로 경로 목록을 사용하며 파일 이름에 글로브를 사용할 수 있습니다. 파일 서비스 검색과 달리 는 inotify를 사용하지 않으며 규칙 파일에 대한 변경 사항을 자동으로 가져오지도 않습니다. 대신 Prometheus를 다시 시작하거나 구성을 다시 로드해야 합니다. rule_files

Prometheus 에 구성을 다시 로드하도록 요청하려면 다음과 같은 명령을 사용하여 SIGHUP신호를 보내면 됩니다:

kill -HUP <pid>

여기서 pid 은 Prometheus의 프로세스 ID입니다. Prometheus의 /-/reload 엔드포인트로 HTTP POST 를 전송할 수도 있지만, 보안상의 이유로 --web.enable-lifecycle 플래그를 지정해야 합니다. 재로드에 실패하면 Prometheus가 이를 기록하고prometheus_config_last_reload_successful 메트릭이 0 으로 변경되는 것을 볼 수 있습니다.

잘못된 구성 파일이나 규칙을 미리 감지하려면 promtool check config 명령을 ...

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