13장. PromQL 소개
이 작품은 AI를 사용하여 번역되었습니다. 여러분의 피드백과 의견을 환영합니다: translation-feedback@oreilly.com
PromQL은 프로메테우스 쿼리 언어입니다. QL로 끝나지만, 시계열에서 수행하려는 계산의 종류에 관해서는 SQL 언어가 표현력이 부족한 경향이 있기 때문에 SQL과 같은 언어는 아닙니다.
레이블은 PromQL의 핵심 부분으로, 임의의 집계를 수행하는 데 사용할 수 있을 뿐만 아니라 서로 다른 메트릭을 결합하여 산술 연산을 수행하는 데에도 사용할 수 있습니다. 예측부터 날짜 및 수학 함수까지 다양한 함수를 사용할 수 있습니다.
이 장에서는 집계, 기본 유형, HTTP API 등 PromQL의 기본 개념에 대해 소개합니다.
집계 기본 사항
몇 가지 간단한 집계 쿼리부터 시작해 보겠습니다. 이러한 쿼리는 PromQL을 사용할 수 있는 대부분의 잠재적 용도를 다룰 것입니다. PromQL은 가능한 한 강력하지만,1 대부분의 경우 요구 사항은 상당히 간단할 것입니다.
게이지
게이지란 상태의 스냅샷으로, 일반적으로 게이지를 집계할 때 합계, 평균, 최소값 또는 최대값을 취합니다.
마운트된 각 파일시스템의 크기를 보고하고 device,fstype, mountpoint 레이블이 있는 노드 익스포터에서 node_filesystem_size_bytes 메트릭을 살펴보세요. 를 사용하여 각 머신의 총 파일시스템 크기를 계산할 수 있습니다:
sum without(device, fstype, mountpoint)(node_filesystem_size_bytes)
without 은 sum 애그리게이터에게 이 세 가지를 무시하고 동일한 레이블로 모든 것을 합산하도록 지시합니다. 따라서 시계열이 있다면
node_filesystem_free_bytes{device="/dev/sda1",fstype="vfat", instance="localhost:9100",job="node",mountpoint="/boot/efi"} 70300672 node_filesystem_free_bytes{device="/dev/sda5",fstype="ext4", instance="localhost:9100",job="node",mountpoint="/"} 30791843840 node_filesystem_free_bytes{device="tmpfs",fstype="tmpfs", instance="localhost:9100",job="node",mountpoint="/run"} 817094656 node_filesystem_free_bytes{device="tmpfs",fstype="tmpfs", instance="localhost:9100",job="node",mountpoint="/run/lock"} 5238784 node_filesystem_free_bytes{device="tmpfs",fstype="tmpfs", instance="localhost:9100",job="node",mountpoint="/run/user/1000"} ...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