Prometheus에서 메트릭 조회하기

Prometheus에서 메트릭 조회하기 (Querying Metrics from Prometheus)

이 작업은 Prometheus를 사용해서 Istio 메트릭을 조회하는 방법을 보여드려요. 작업 과정에서 웹 기반 인터페이스를 사용해서 메트릭 값을 조회하게 돼요. 예시 애플리케이션으로는 Bookinfo 샘플 애플리케이션을 사용해요.

출처: Istio 문서

본문

이 작업은 Prometheus를 사용해서 Istio 메트릭을 조회하는 방법을 보여드려요. 작업 과정에서 메트릭 값을 조회하기 위해 웹 기반 인터페이스를 사용하게 돼요. 이 작업 전체에서 예시 애플리케이션으로 Bookinfo 샘플 애플리케이션을 사용해요.

시작하기 전에 (Before you begin)

  • 클러스터에 Istio를 설치하세요.
  • Prometheus Addon을 설치하세요.
  • Bookinfo 애플리케이션을 배포하세요.

Istio 메트릭 조회하기 (Querying Istio metrics)

  1. prometheus 서비스가 클러스터에서 실행 중인지 확인하세요. Kubernetes 환경에서는 다음 명령을 실행하세요.
$ kubectl -n istio-system get svc prometheus
NAME         TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
prometheus   ClusterIP   10.109.160.254   <none>        9090/TCP   4m
  1. 메시로 트래픽을 보내세요. Bookinfo 샘플의 경우 웹 브라우저에서 http://$GATEWAY_URL/productpage에 접속하거나 다음 명령을 실행하세요.
$ curl "http://$GATEWAY_URL/productpage"

[!note] $GATEWAY_URL은 Bookinfo 예시에서 설정한 값이에요.

  1. Prometheus UI를 여세요. Kubernetes 환경에서는 다음 명령을 실행하세요.
$ istioctl dashboard prometheus

헤더에서 Prometheus 오른쪽의 Graph를 클릭하세요. 4. Prometheus 쿼리를 실행하세요. 웹 페이지 상단의 "Expression" 입력 상자에 다음 텍스트를 입력하세요.

istio_requests_total

그 다음 Execute 버튼을 클릭하세요. 결과는 다음과 비슷할 거예요. Execute 버튼 아래의 Graph 탭을 선택하면 쿼리 결과를 그래픽으로도 볼 수 있어요. 다른 시도해 볼 수 있는 쿼리들:

  • productpage 서비스로의 모든 요청 총 개수:
istio_requests_total{destination_service="productpage.default.svc.cluster.local"}
  • reviews 서비스의 v3로의 모든 요청 총 개수:
istio_requests_total{destination_service="reviews.default.svc.cluster.local", destination_version="v3"}

이 쿼리는 reviews 서비스의 v3로의 모든 요청의 현재 총 개수를 반환해요.

  • 지난 5분 동안 productpage 서비스의 모든 인스턴스로의 요청 비율:
rate(istio_requests_total{destination_service=~"productpage.*", response_code="200"}[5m])

Prometheus 애드온에 대해 (About the Prometheus addon)

Prometheus 애드온은 Istio 엔드포인트를 스크래핑해서 메트릭을 수집하도록 사전 구성된 Prometheus 서버예요. Istio 메트릭의 영구 저장과 조회를 위한 메커니즘을 제공해요. Prometheus 조회에 대해 더 알고 싶다면 Prometheus의 조회 문서를 읽어보세요.

정리 (Cleanup)

  • 아직 실행 중일 수 있는 istioctl 프로세스를 control-C 또는 다음 명령으로 종료하세요.
$ killall istioctl
  • 후속 작업을 탐구할 계획이 없다면 Bookinfo 정리 지침을 참고해서 애플리케이션을 종료하세요.

더 알아보기 (Learn more)

  • Prometheus 조회 언어와 함수에 대한 자세한 내용은 Prometheus 공식 문서를 참고하세요.
  • Istio에서 생성하는 표준 메트릭들에 대해서는 "기본 메트릭" 문서를 참고하세요.