Prometheus & Grafana 설치하기

Prometheus & Grafana 설치하기

Prometheus

Prometheus는 시계열 데이터베이스 및 수집도구라고 정의할 수 있다. 주기적으로 수집 대상의 Endpoint에 HTTP Request를 요청하여 데이터를 수집하고, 내부 데이터베이스에 적재하는 Pull system이다. 매 순간의 수치를 가져와서 TimeStamp를 붙여주고 관리해주는 시스템이다 보니, 흘러가는 데이터들을 가져와서 수집하기가 용이하다.

그리고 PromQL 이라는 자체 쿼리 언어로 손쉽게 시계열 데이터를 추출하고 커스터마이즈 할 수 있다. 이렇게 시계열 데이터 처리에 최적화되어 있기 때문에 복잡한 시계열 데이터를 원하는 대로 변형할 수 있다.

설치하기 (공식문서)

1. 패키지 매니저와 systemd 사용하여 실행

$ sudo useradd --no-create-home --shell /usr/sbin/nologin prometheus

2. Prometheus 설치

$ sudo apt-get update -y $ sudo apt-get install -y prometheus prometheus-node-exporter prometheus-pushgateway prometheus-alertmanager

3. 서비스 등록 및 시작

$ sudo systemctl start prometheus $ sudo systemctl enable prometheus

4. 설치 및 기동 확인

5. Docker로 실행

$ docker run \ -p 9090:9090 \ -v /tmp/prometheus.yml:/etc/prometheus/prometheus.yml \ prom/prometheus

6. localhost:9090 접속

Grafana

Grafana는 Prometheus르 비롯한 다양한 데이터 소스로부터 주로 시계열 데이터를 가져와 시각화하고 대시보드를 만들어주는 도구이다. 다양한 시각화 기능과 데이터소스, Alarm 및 Notification 기능을 제공한다.

설치하기

1. Repository 추가 및 key 다운로드, 설치

$ sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main" $ curl https://packages.grafana.com/gpg.key | sudo apt-key add - $ sudo apt-get update $ sudo apt-get install grafana

2. 서비스 등록 및 시작

$ sudo systemctl daemon-reload $ sudo systemctl start grafana-server $ sudo systemctl enable grafana-server

3. 설치 및 기동 확인

4. localhost:3000 접속

- 최초 계정은 admin / admin

Reference

from http://havving-do-it.tistory.com/205 by ccl(A) rewrite - 2021-09-07 11:26:51