데이터 엔지니어링/Prometheus

[Prometheus] Prometheus

pythaac 2022. 7. 16. 15:23

https://prometheus.io/docs/introduction/overview/

 

Overview | Prometheus

An open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach.

prometheus.io

 

정의

  • 모니터링 / 알람 툴킷
  • time series data로 metric을 수집 / 저장

 

기능

  • Multi-dimensional time series data model
  • PromQL
  • 분산 스토리지에 의존 X
  • HTTP를 이용한 pull 방식
  • Gateway를 통한 push 방식 지원
  • Target discovery (service discovery / static configuration)
  • 다양한 그래프 / 대시보드 지원

 

Metric이란

  • Terms
    • Metric : 수치 측정
    • Time series : 시간에 따른 변화 기록
  • application마다 측정하고자하는 것이 다름
    • Web server
      - request 횟수
    • Database
      - active connection 수
      - active query 수
  • 역할
    • application의 정상 작동 확인
    • 예시
      • web application이 느려진 것이 확인됨
      • 이를 진단하기 위한 정보가 필요
      • ex) request 수가 높아져 느려질 수 있음
      • 이와 관련된 metric을 수집하고 있다면 원인을 파악하여 server 수를 늘릴 수 있음

 

컴포넌트

https://prometheus.io/docs/introduction/overview/

  • Promehteus server
    - time series data를 모으고 저장
  • Client Library
    - application 코드 계측(instrument)
  • Push Gateway
    - short-lived job 지원을 위한
  • Exporter
    - HAProxy, StatsD, Graphite와 같은 서비스
  • Altermanager
    - alert 관리

 

동작 방식

  • Metric 수집
    • 계측된 job(instrumented job)에서 metric 수집
      - 1) 직접
      - 2) push gateway
  • 저장 및 Rule 실행
    • sample을 local에 저장
    • 이 데이터에 대한 Rule 실행
      - 기존 데이터로부터 새로운 time series를 집계/기록
      - alert 생성
  • 데이터 사용
    • Grafana와 같은 API consumer로 수집 데이터 visualization

 

적합/부적합

  • 적합
    • numeric time series 기록
    • machine 중심 모니터링
    • 변동성이 높은(highly dynamic) 서비스 지향 아키텍처
    • 마이크로서비스
      - multi-dimensional data 수집/쿼리
  • 특징
    • 빠른 문제 진단이 가능한 안전성을 위한 설계
    • Standalone
      - 다른 remote service에 의존하지 않음
      - 광범위한 인프라 설치가 필요 없음
  • 부적합
    • 정확도가 필요할 경우
    • billing system
      - request마다 처리해야할 경우 (per-request billing)
    • 소량의 데이터도 소실되면 안되는 경우

https://stackoverflow.com/questions/44518575/why-can-not-we-use-prometheus-as-billing-system

 

Why can not we use prometheus as billing system?

I want to know why prometheus is not suitable for billing system. the Prometheus overview page says If you need 100% accuracy, such as for per-request billing, Prometheus is not a good choice as ...

stackoverflow.com