newtype
::: newtype의 지식창고 :::
newtype
전체 방문자
오늘
어제
  • 분류 전체보기 (392)
    • Dev (214)
      • C, C++ (43)
      • Go (5)
      • Web (49)
      • DBMS (21)
      • DevOps (8)
      • Java (2)
      • Windows, Win32 (4)
      • Visual Basic (5)
      • C# (2)
      • Mobile (25)
      • SQL CE (7)
      • Google Map (6)
      • Python (2)
      • cygwin (2)
      • 기타 (32)
      • Ruby (1)
    • 명언 (10)
    • 모임 (18)
      • 붕주회 (3)
      • 신흥컴정 (14)
      • 웹20기 (1)
    • 사진 (8)
    • 불펌 (29)
    • 막글 (98)
    • 게임 (6)
    • 여행 (8)

블로그 메뉴

  • 홈
  • 태그
  • 방명록
  • 관리

공지사항

  • whoami
05-13 00:00
hELLO · Designed By 정상우.
newtype

::: newtype의 지식창고 :::

Dev/DevOps

nats - prometheus 연동

2022. 9. 5. 17:47

목적

  • nats -> prometheus -> grafana 구성으로 모니터링 환경을 구축 하려고 한다.

방법

  1. nats와 prometheus 모니터링을 하기위해, nats 서버에 prometheus-nats-exporter를 설치 해야한다.

  2. nats와 nats-exporter 연동을 위해서는 nats-server 기동시 -m 옵션으로 모니터링 포트를 지정해야한다.

nats-server -p 4222 -m 8222
  1. nats-exporter를 기동한다.
prometheus-nats-exporter -varz -jsz=all http://127.0.0.1:8222

nats-exporter가 nats-server보다 먼저 기동되어서는 안된다. 8222 포트가 listen 된것을 확인하고, 기동해야 정상적으로 연동된다.

  1. nats-exporter가 기동되면 7777 port를 통해 metrics를 조회할 수 있다
curl http://127.0.0.1:8222/metrics | grep ^gnatsd_varz
  1. nasts-exporter와 prometheus가 연동 할 수 있도록 prometheus.yml 파일을 수정한다.

    prometheus.tml 파일은 /etc/config/Prometheus.yml에 위치하는데, kubenetes로 설치하는 경우 ConfigMaps 수정을 통해 적용이 가능한다.

  • ConfigMap 수정

    prometheus.yml: 아래 scrape_configs:가 있고, 그 아래 - job_name: xxxxxx이 존재하는데, 같은 depth에 아래와 같이 추가한다. 여러개가 있으면 targets 아래 나열해도 되고, job_name을 여러개 추가해도 된다. job_name을 여러개 추가하는 것이 나중에 grafans에서 (ip가 아니라 이름으로 보이므로) 보기에 좋다.

$ kubectl -n prometheus edit cm prometheus-server 
- job_name: nats-exporter-xxxxxxx1
  static_configs:
  - targets:
    - xxx.xxx.xxx.xxx:7777
  • replicas를 1 -> 0 -> 1로 변경

    이렇게 하면 prometheus-server pod가 삭제되었다가 생성된다.

  1. grafana에 nats dashboard를 추가한다.

https://github.com/nats-io/prometheus-nats-exporter/blob/main/walkthrough/grafana-nats-dash.json

반응형
저작자표시

'Dev > DevOps' 카테고리의 다른 글

Redis 성능 향상 방법  (0) 2022.10.13
Redis Cluster 구성  (0) 2022.10.12
prompt에 kubernetes context 표시하기  (0) 2022.09.16
Grafana와 EFS 연동  (0) 2022.08.29
promethues 쿼리 몇 가지  (0) 2022.08.22
    'Dev/DevOps' 카테고리의 다른 글
    • Redis Cluster 구성
    • prompt에 kubernetes context 표시하기
    • Grafana와 EFS 연동
    • promethues 쿼리 몇 가지
    newtype
    newtype
    지극히 개인적인 지식의 창고

    티스토리툴바