QueryPie Monitoring 설치 가이드

QueryPie Monitoring 설치 가이드

소개

본 가이드는 QueryPie 인스턴스 모니터링 환경 설정 방법을 설명합니다. monitoring.tar 파일을 서버에 업로드하고 압축을 해제하는 과정을 포함합니다. 여러 개의 QueryPie 인스턴스를 운영하는 경우 각 노드별로 설정이 필요합니다.

목표

본 가이드를 통해 파트너는 QueryPie 인스턴스의 상태를 실시간으로 모니터링하고 잠재적인 문제를 사전에 감지하여 안정적인 운영 환경을 구축할 수 있습니다.

사전 요구 사항

  • QueryPie Docker 인스턴스가 설치된 환경

  • 통신 확인 (https://raw.githubusercontent.com/querypie/tpm/main/querypie-monitoring)

  • 서버 접근 권한 (SSH 등)

예상 소요 시간

약 30분

설치 과정 요약

  1. 모니터링 스크립트 다운로드 및 실행

  2. 모니터링 환경 실행: Docker Compose를 사용하여 Prometheus, Grafana 등의 모니터링 도구 실행

  3. 상태 확인: Grafana 및 Prometheus 접속 후 데이터 소스와 메트릭 수집 상태 점검

  4. 모니터링 중단: Docker Compose를 사용하여 모니터링 환경 중단 또는 완전 삭제

  5. Prometheus 데이터 관리: 데이터 보존 기간 설정, 디스크 사용량 모니터링 및 수동 데이터 정리


1. 모니터링 스크립트 다운로드 및 실행

  1. 모니터링 디렉토리 생성

    mkdir querypie-monitoring cd querypie-monitoring
  2. 모니터링 스크립트 다운로드

    curl -O https://raw.githubusercontent.com/querypie/tpm/main/querypie-monitoring/monitoring.sh
  3. 스크립트 실행 권한 부여 및 실행:

    chmod +x monitoring.sh ./monitoring.sh setup
  4. 결과:

    [INFO] Starting QueryPie monitoring setup... [INFO] Checking prerequisites... [INFO] All prerequisites are satisfied [INFO] Setting up monitoring directory... [INFO] Downloading monitoring files... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 1047k 0 1047k 0 0 938k 0 --:--:-- 0:00:01 --:--:-- 4455k [INFO] Setting execute permission for monitoring.sh... [INFO] Execute permission set. [INFO] Monitoring directory setup completed [INFO] Getting QueryPie container information... [INFO] Found QueryPie container: querypie-app-1 [INFO] Found QueryPie container network: querypie_default [INFO] Setting up MySQL configuration... [INFO] Using MySQL Host: 172.31.47.166 [INFO] Creating directory structure... [INFO] Copying dashboard files... [INFO] Creating Prometheus configuration... [INFO] Creating Procstat configuration... [INFO] Creating monitoring compose file... [INFO] Creating Grafana datasource configuration... [INFO] Creating Grafana dashboard provisioning configuration... [INFO] Setup completed successfully!
    • setup-monitoring.sh 스크립트는 Docker Compose 환경 구성에 필요한 ./etc, ./grafana, ./prometheus, monitoring.yml 파일을 생성합니다.


2. 모니터링 환경 실행

  • 다음 명령어를 사용하여 모니터링 환경을 백그라운드에서 실행합니다:

    ./monitoring.sh up
    • 이 명령어는 Prometheus (메트릭 수집), Grafana (대시보드 시각화), procstat (시스템 메트릭) 컨테이너를 실행합니다.

      ./monitoring.sh up [INFO] Starting monitoring services... [+] Running 22/22 ⠿ prometheus Pulled 9.0s ⠿ 9fa9226be034 Pull complete 2.8s ⠿ 1617e25568b2 Pull complete 3.2s ⠿ 731950a2359b Pull complete 4.5s ⠿ 0798be59a2ec Pull complete 5.6s ⠿ 8e09b17d2ea5 Pull complete 5.7s ⠿ 6c7f11bc0a1a Pull complete 5.7s ⠿ 506370f36b89 Pull complete 5.8s ⠿ c0458882568a Pull complete 5.8s ⠿ 765c668714d4 Pull complete 6.1s ⠿ f833206956cf Pull complete 6.1s ⠿ grafana Pulled 11.0s ⠿ da9db072f522 Pull complete 0.7s ⠿ eb724a2c4954 Pull complete 0.8s ⠿ 082ff8086b23 Pull complete 1.0s ⠿ 5d14cfaa511e Pull complete 1.3s ⠿ c05f5007886b Pull complete 1.3s ⠿ 16819baaa32d Pull complete 1.3s ⠿ 557cb0193fc4 Pull complete 3.9s ⠿ 8821fea706d0 Pull complete 7.9s ⠿ dfa49a55d740 Pull complete 8.0s ⠿ 915f3104e60f Pull complete 8.1s [+] Running 4/4 ⠿ Volume "querypie-monitoring_prometheus_data" Created 0.0s ⠿ Container procstat Started 2.6s ⠿ Container prometheus Started 2.5s ⠿ Container grafana Started 2.6s [INFO] Monitoring services started successfully! 6.5s
  • 다음 명령어를 사용하여 확인합니다:

    docker ps
    • 결과

      docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 21dd066d6482 grafana/grafana:11.3.1 "/run.sh" 18 seconds ago Up 15 seconds 0.0.0.0:3000->3000/tcp, :::3000->3000/tcp grafana d2f74e6ff96d prom/prometheus:v3.0.0 "/bin/prometheus --c…" 18 seconds ago Up 15 seconds 0.0.0.0:9090->9090/tcp, :::9090->9090/tcp prometheus 19dc8596f7ba ncabatoff/process-exporter:sha-e2a9f0d "/bin/process-export…" 18 seconds ago Up 15 seconds 0.0.0.0:9256->9256/tcp, :::9256->9256/tcp procstat cbdd1295a21a harbor.chequer.io/querypie/querypie:10.2.9 "/usr/local/bin/dock…" 4 days ago Up 5 hours 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp, 0.0.0.0:6443->6443/tcp, :::6443->6443/tcp, 0.0.0.0:7447->7447/tcp, :::7447->7447/tcp, 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp, 0.0.0.0:40000-40030->40000-40030/tcp, :::40000-40030->40000-40030/tcp querypie-app-1 2b3f3329cb57 mysql:8.0.36 "docker-entrypoint.s…" 4 days ago Up 5 hours querypie-mysql-1 c56c6bba06b6 redis:7.4.2 "docker-entrypoint.s…" 4 days ago Up 5 hours querypie-redis-1

 


3. 상태 확인

  1. 접속 확인:

    • Grafana: http://{instance-ip}:3000/dashboards

    • Prometheus: http://{instance-ip}:9090

  2. Grafana 서비스 동작 확인:

    • Grafana 주소로 접속했을 때 페이지가 잘 뜨는지 확인합니다.

    • Grafana UI 안에서,
      Connections > Data Sources 메뉴에서 Prometheus 클릭 후 맨 아래쪽에 Test 클릭합니다.

      Successfully queried the Prometheus API. Next, you can start to visualize data by building a dashboard, or by querying data in the Explore view.
  3. Prometheus 서비스 동작 확인:

    • Prometheus 주소로 접속했을 때 페이지가 잘 뜨는지 확인합니다.

    • Prometheus UI 안에서,
      Status > Target health 메뉴로 이동하여 수집 대상들(procstat, prometheus, querypie)의 상태가 UP 인지 확인합니다.


4. 모니터링 중단

  • 모니터링 환경 중단:

    ./monitoring.sh down

5. Prometheus 데이터 관리

  1. 데이터 보존 기간 설정 (monitoring.yml 수정가능):

    prometheus: command: - '--config.file=/etc/prometheus/prometheus.yml' - '--storage.tsdb.path=/prometheus' - '--storage.tsdb.retention.time=15d' # 데이터 보존 기간 (예: 15일) - '--storage.tsdb.retention.size=50GB' # 최대 저장 용량 - '--web.enable-lifecycle'
  2. 디스크 사용량 모니터링:

    • 볼륨 사용량 확인:

      docker system df -v | grep prometheus_data
    • 상세 용량 확인:

      sudo du -sh /var/lib/docker/volumes/querypie-monitoring_prometheus_data/_data
  3. 수동 데이터 정리:

    • 전체 데이터 삭제:

      ./monitoring.sh down docker volume rm querypie-monitoring_prometheus_data

권장 설정

  • 데이터 보존 기간: 15일

  • 최대 저장 용량: 시스템 디스크의 20% 이하

  • 정기적인 모니터링: 디스크 사용량이 80% 초과 시 조치

문제 해결

  • Grafana 또는 Prometheus 접속 불가: 방화벽 설정 및 포트 충돌 여부 확인

  • 데이터 소스 연결 실패: Prometheus 설정 확인 및 재시작

  • 메트릭 데이터 미수집: QueryPie API, Engine, Arisa 상태 확인 및 재시작

최종 확인 사항

  • Grafana 대시보드에서 QueryPie 관련 메트릭이 정상적으로 표시되는지 확인

  • Prometheus에서 QueryPie 타겟들의 상태가 "UP"인지 확인

  • 디스크 사용량이 권장 범위 내에 있는지 확인

참고 자료

⚠️주의사항

  • 각 인스턴스별로 독립적인 모니터링 환경을 구성해야 합니다.

  • Grafana 대시보드는 익명 접속이 활성화되어 있습니다. 관리자 계정으로 로그인하려면 아래 설정을 적용하세요.

Grafana 관리자 계정 설정

기존에 설치된 Grafana에 인증 부분을 적용하려면 monitoring.yml 파일에서 grafana 부분을 다음과 같이 수정하세요.

vi monitoring.yml
grafana: image: grafana/grafana:11.3.1 container_name: grafana ports: - "3000:3000" networks: - querypie_default volumes: - ./grafana/provisioning:/etc/grafana/provisioning - ./grafana/dashboards:/var/lib/grafana/dashboards environment: #- GF_AUTH_ANONYMOUS_ENABLED=true #기존 파일 주석 #- GF_AUTH_ANONYMOUS_ORG_ROLE=Admin #기존 파일 주석 #- GF_AUTH_DISABLE_LOGIN_FORM=true #기존 파일 주석 - GF_AUTH_ANONYMOUS_ENABLED=false # 익명 접속 비활성화 - GF_AUTH_DISABLE_LOGIN_FORM=false # 로그인 폼 활성화 - GF_SECURITY_ADMIN_USER=admin # 관리자 사용자 이름 설정 - GF_SECURITY_ADMIN_PASSWORD=querypie # 관리자 비밀번호 설정 restart: unless-stopped

위 설정을 적용한 후 ./monitoring.sh down , ./monitoring.sh up 명령어를 실행하여 Grafana를 재시작하면, admin 계정과 querypie 비밀번호로 로그인할 수 있습니다.