웹사이트 검색

Ubuntu 20.04에서 Grafana 및 Prometheus로 MongoDB를 모니터링하는 방법


저자는 Write for DOnations 프로그램을 선택했습니다.

소개

성능 또는 메모리 문제를 피하는 것은 데이터베이스 관리자에게 매우 중요합니다. 시계열 데이터와 같은 도구. Grafana는 대화형 시각화 및 분석을 위한 오픈 소스 웹 애플리케이션입니다. 이를 통해 방대한 수의 데이터 소스에서 데이터를 수집하고, 이 데이터를 쿼리하고, 쉽게 분석할 수 있도록 사용자 지정 가능한 차트에 표시할 수 있습니다. 예기치 않은 동작을 빠르고 쉽게 알 수 있도록 경고를 설정할 수도 있습니다. 함께 사용하면 MongoDB 인스턴스에서 데이터를 수집, 모니터링, 분석 및 시각화할 수 있습니다.

이 튜토리얼에서는 Prometheus를 데이터 소스로 사용하여 MongoDB 데이터베이스를 설정하고 Grafana로 모니터링합니다. 이를 위해 Prometheus가 데이터베이스 메트릭을 스크랩하고 Grafana에서 사용할 수 있도록 MongoDB 내보내기를 Prometheus 대상으로 구성합니다.

전제 조건

이 자습서를 따르려면 다음이 필요합니다.

  • 루트가 아닌 사용자가 sudo 권한이 있고 방화벽이 ufw로 구성된 Ubuntu 20.04 서버 1개(Ubuntu용 초기 서버 설정 가이드에 따라 수행할 수 있음) 20.04.
  • Ubuntu 20.04 서버에 MongoDB를 설치했습니다. Ubuntu 20.04에 MongoDB를 설치하는 방법 튜토리얼을 따라 수행할 수 있습니다.
  • Ubuntu 20.04 서버에 Grafana 설치. Ubuntu 20.04에서 Grafana를 설치하고 보호하는 방법 자습서의 1~4단계를 수행할 수 있습니다.

Grafana를 설치하려면 다음이 필요합니다.

  • 완전히 등록된 도메인 이름. 이 자습서에서는 전체적으로 your_domain을 사용합니다. Freenom에서 도메인 이름을 구입하거나 선택한 도메인 등록 기관을 사용할 수 있습니다.
  • 다음 DNS 레코드는 서버에 대해 설정됩니다. DigitalOcean을 사용하는 경우 추가 방법에 대한 자세한 내용은 도메인 추가 방법 문서를 참조하십시오.\n
    • 서버의 공용 IP 주소를 가리키는 your_domain이 있는 A 레코드
    • 서버의 공용 IP 주소를 가리키는 www.your_domain이 있는 A 레코드

    1단계 - Prometheus 설치 및 구성

    Prometheus는 지표를 시계열 데이터로 수집하고 저장하는 오픈 소스 시스템 모니터링 및 경고 툴킷입니다. 즉, 메트릭 정보는 기록된 타임스탬프와 함께 저장됩니다. 이 단계에서는 Prometheus를 설치하고 서비스로 실행되도록 구성합니다.

    프로메테우스 설치

    먼저 Prometheus를 설치해야 합니다. 다음과 같이 서버에 로그인하고 패키지 목록을 업데이트하여 시작하십시오.

    1. sudo apt update

    다음으로 Prometheus의 구성 및 데이터 디렉토리를 생성합니다. prometheus라는 구성 디렉토리를 생성하려면 다음 명령을 실행합니다.

    1. sudo mkdir -p /etc/prometheus

    다음으로 데이터 디렉터리를 만듭니다.

    1. sudo mkdir -p /var/lib/prometheus

    디렉터리를 만든 후 압축된 설치 파일을 다운로드합니다. Prometheus 설치 파일은 압축 파일로 미리 컴파일된 바이너리로 제공됩니다. Prometheus를 다운로드하려면 다운로드 페이지를 방문하십시오.

    2.31.0 버전을 다운로드하려면 다음 명령을 실행하고 필요에 따라 버전 번호를 바꿉니다.

    1. wget https://github.com/prometheus/prometheus/releases/download/v2.31.0/prometheus-2.31.0.linux-amd64.tar.gz

    다운로드가 완료되면 tarball 파일의 압축을 풉니다.

    1. tar -xvf prometheus-2.31.0.linux-amd64.tar.gz

    파일을 추출한 후 Prometheus 폴더로 이동합니다.

    1. cd prometheus-2.31.0.linux-amd64

    그런 다음 prometheuspromtool 바이너리 파일을 /usr/local/bin/ 디렉터리로 이동합니다.

    1. sudo mv prometheus promtool /usr/local/bin/

    다음으로 Prometheus와 관련된 모든 파일을 /etc/prometheus/의 한 위치로 이동합니다. consoles 디렉터리의 콘솔 파일과 console_libraries 디렉터리의 라이브러리 파일을 이동하려면 다음 명령을 실행합니다.

    1. sudo mv consoles/ console_libraries/ /etc/prometheus/

    콘솔 및 콘솔 라이브러리 파일은 Prometheus GUI를 시작하는 데 사용됩니다. 이러한 파일은 서비스를 시작하는 동안 사용할 수 있도록 구성 파일과 함께 보관됩니다.

    마지막으로 prometheus.yml 템플릿 구성 파일을 /etc/prometheus/ 디렉터리로 이동합니다.

    1. sudo mv prometheus.yml /etc/prometheus/prometheus.yml

    prometheus.yml은 Prometheus용 포트를 구성하고 서비스를 시작하는 동안 사용할 파일을 구성할 템플릿 구성 파일입니다.

    설치된 Prometheus 버전을 확인하려면 다음 명령을 실행하십시오.

    1. prometheus --version

    다음과 유사한 출력이 표시됩니다.

    Output
    prometheus, version 2.31.0 (branch: HEAD, revision: b41e0750abf5cc18d8233161560731de05199330) build user: root@0aa1b7fc430d build date: 20220714-15:13:18 go version: go1.18.4 platform: linux/amd64

    이 섹션에서는 Prometheus를 설치하고 해당 버전을 확인했습니다. 다음으로 서비스로 시작합니다.

    프로메테우스를 서비스로 실행하기

    이제 Prometheus를 설치했으므로 서비스로 실행되도록 구성합니다.

    이를 수행하기 위해 시스템 파일을 생성하기 전에 Prometheus 그룹 및 사용자를 생성해야 합니다. 필요한 디렉토리에 대한 소유자 액세스 권한이 있는 전용 사용자가 필요합니다. prometheus 그룹을 만들려면 다음 명령을 실행합니다.

    1. sudo groupadd --system prometheus

    다음으로 prometheus 사용자를 만들고 방금 만든 prometheus 그룹에 할당합니다.

    1. sudo useradd -s /sbin/nologin --system -g prometheus prometheus

    전용 사용자가 올바른 권한을 갖도록 다음과 같이 디렉터리 소유권 및 권한을 변경합니다.

    1. sudo chown -R prometheus:prometheus /etc/prometheus/ /var/lib/prometheus/
    2. sudo chmod -R 775 /etc/prometheus/ /var/lib/prometheus/

    다음으로 Prometheus를 서비스로 실행하기 위한 서비스 파일을 생성합니다. nano 또는 선호하는 텍스트 편집기를 사용하여 prometheus.service라는 systemd 서비스 파일을 만듭니다.

    1. sudo nano /etc/systemd/system/prometheus.service

    다음 코드 줄을 추가합니다.

    [Unit]
    Description=Prometheus
    Wants=network-online.target
    After=network-online.target
    
    [Service]
    User=prometheus
    Group=prometheus
    Restart=always
    Type=simple
    ExecStart=/usr/local/bin/prometheus \
        --config.file=/etc/prometheus/prometheus.yml \
        --storage.tsdb.path=/var/lib/prometheus/ \
        --web.console.templates=/etc/prometheus/consoles \
        --web.console.libraries=/etc/prometheus/console_libraries \
        --web.listen-address=0.0.0.0:9090
    
    [Install]
    WantedBy=multi-user.target
    

    이 코드를 사용하여 ExecStart 블록에 나열된 파일을 사용하여 서비스를 실행하도록 Prometheus를 구성합니다. 서비스 파일은 구성 파일 /etc/prometheus/prometheus.yml을 사용하여 Prometheus를 prometheus 사용자로 실행하고 해당 데이터를 저장하도록 systemd에 지시합니다. /var/lib/prometheus 디렉토리에 있습니다. 또한 포트 9090에서 실행되도록 Prometheus를 구성합니다. (systemd 서비스 파일에 대한 자세한 내용은 이 자습서의 범위를 벗어나지만 시스템 단위 및 단위 파일 이해에서 자세히 알아볼 수 있습니다.)

    파일을 저장하고 닫습니다. nano를 사용하는 경우 CTRL+X를 누른 다음 Y를 누릅니다.

    이제 Prometheus 서비스를 시작합니다.

    1. sudo systemctl start prometheus

    시작 시 실행되도록 Prometheus 서비스를 활성화합니다.

    1. sudo systemctl enable prometheus

    다음 명령을 사용하여 서비스 상태를 확인할 수 있습니다.

    1. sudo systemctl status prometheus

    출력은 서비스가 활성(실행 중)임을 확인합니다.

    ● prometheus.service - Prometheus
         Loaded: loaded (/etc/systemd/system/prometheus.service; enabled; vendor preset: enabled)
         Active: active (running) since Fri 2022-08-05 18:06:05 UTC; 13s ago
       Main PID: 7177 (prometheus)
          Tasks: 6 (limit: 527)
         Memory: 21.0M
         CGroup: /system.slice/prometheus.service
                 └─7177 /usr/local/bin/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus/ --web.console.template>
    

    Prometheus에 액세스하려면 브라우저를 실행하고 포트 9090 다음에 서버의 IP 주소를 방문하십시오: http://your_server_ip:9090.

    참고: Prometheus 웹 콘솔에 액세스하려면 서버에서 포트 9090을 허용해야 할 수 있습니다. 현재 UFW 규칙 세트를 확인하려면 다음 명령을 실행하십시오.

    1. sudo ufw status

    포트 9090이 아직 허용되지 않은 경우 다음 명령을 사용하여 포트를 추가할 수 있습니다.

    1. sudo ufw allow 9090

    이제 Prometheus 웹 콘솔에 액세스할 수 있습니다.

    이 단계에서는 Prometheus를 설치하고 서비스로 실행되도록 구성했습니다. 다음으로 MongoDB 내보내기를 사용하여 MongoDB 데이터베이스를 Prometheus에 바인딩합니다.

    2단계 - MongoDB 내보내기 구성

    Prometheus는 지표를 수집하기 위해 대상을 스크래핑하는 방식으로 작동합니다. 이 단계에서는 MongoDB 내보내기 프로그램을 설치하고 Prometheus가 MongoDB 인스턴스에서 데이터를 수집할 수 있도록 Prometheus 대상으로 구성합니다.

    MongoDB 익스포터 설치

    이 섹션에서는 MongoDB 내보내기를 설치합니다. 먼저 내보내기를 위한 디렉터리를 생성하고 해당 디렉터리로 이동합니다.

    1. mkdir mongodb-exporter
    2. cd mongodb-exporter

    MongoDB 내보내기는 Github에서 다운로드할 수 있습니다. 내보내기는 아카이브에서 바이너리 파일로 제공되지만 이를 서비스로 구성합니다. 다음 명령을 사용하여 바이너리 파일을 다운로드합니다.

    1. wget https://github.com/percona/mongodb_exporter/releases/download/v0.7.1/mongodb_exporter-0.7.1.linux-amd64.tar.gz

    다음으로 다운로드한 아카이브를 현재 폴더에 추출합니다.

    1. tar xvzf mongodb_exporter-0.7.1.linux-amd64.tar.gz

    마지막으로 mongodb_exporter 바이너리를 usr/local/bin/으로 이동합니다.

    1. sudo mv mongodb_exporter /usr/local/bin/

    이 섹션에서는 MongoDB 내보내기를 설치했습니다. 다음으로 MongoDB 인증을 활성화하고 모니터링할 사용자를 만듭니다.

    MongoDB 인증 활성화

    이 섹션에서는 MongoDB 내보내기에 대한 MongoDB 인증을 설정하고 클러스터의 메트릭을 모니터링할 사용자를 생성합니다.

    mongo를 사용하여 MongoDB 인스턴스에 연결하여 시작합니다.

    1. mongo

    클러스터 모니터 역할을 사용하여 내보내기에 대한 관리자 계정을 생성합니다. admin 데이터베이스로 전환합니다.

    1. use admin

    admin 데이터베이스로 전환한 후 clusterMonitor 역할을 가진 사용자를 생성합니다.

    1. db.createUser({user: "test",pwd: "testing",roles: [{ role: "clusterMonitor", db: "admin" },{ role: "read", db: "local" }]})

    다음과 같은 결과가 표시됩니다.

    Successfully added user: {
            "user" : "test",
            "roles" : [
                    {
                            "role" : "clusterMonitor",
                            "db" : "admin"
                    },
                    {
                            "role" : "read",
                            "db" : "local"
                    }
            ]
    }
    

    사용자를 만든 후 MongoDB 셸을 종료합니다.

    1. exit

    다음으로 적절한 인증 자격 증명을 사용하여 MongoDB URI 환경 변수를 설정합니다.

    export MONGODB_URI=mongodb://test:testing@localhost:27017
    

    MONGODB_URI를 설정하여 이전에 설정한 인증 자격 증명을 사용하는 mongodb 인스턴스(test 사용자 및 테스트 암호). 27017mongodb 인스턴스의 기본 포트입니다. 환경 변수를 설정하면 구성 파일에 저장된 프로필보다 우선합니다.

    MongoDO URI 환경 변수가 올바르게 설정되었는지 확인하려면 다음 명령을 실행하십시오.

    1. env | grep mongodb

    다음과 같은 결과가 표시됩니다.

    MONGODB_URI=mongodb://mongodb_exporter:password@localhost:27017
    

    이 섹션에서는 클러스터 메트릭을 모니터링하는 데 도움이 되는 clusterMonitor 역할이 있는 MongoDB 사용자를 생성했습니다. 다음으로 서비스로 실행되도록 MongoDB 내보내기를 구성합니다.

    MongoDB 내보내기용 서비스 만들기

    이 섹션에서는 MongoDB 내보내기용 시스템 파일을 만들고 서비스로 실행합니다.

    /lib/systemd/system으로 이동하고 nano 또는 즐겨 사용하는 텍스트 편집기를 사용하여 내보내기를 위한 새 서비스 파일을 만듭니다.

    1. cd /lib/systemd/system/
    2. sudo nano mongodb_exporter.service

    다음 구성을 서비스 파일에 붙여넣습니다.

    [Unit]
    Description=MongoDB Exporter
    User=prometheus
    
    [Service]
    Type=simple
    Restart=always
    ExecStart=/usr/local/bin/mongodb_exporter
    
    [Install]
    WantedBy=multi-user.target
    

    이 서비스 파일은 systemd에게 prometheus 사용자의 서비스로 MongoDB 내보내기를 실행하도록 지시합니다. ExecStartusr/local/bin/에서 mongodb_exporter 바이너리를 실행합니다. systemd 서비스 파일에 대한 자세한 내용은 시스템 단위 및 단위 파일 이해를 확인하세요.

    파일을 저장하고 닫습니다.

    다음으로 시스템 데몬을 다시 시작하여 장치 파일을 다시 로드합니다.

    1. sudo systemctl daemon-reload

    이제 서비스를 시작하십시오.

    1. sudo systemctl start mongodb_exporter.service

    MongoDB 내보내기 서비스의 상태를 확인하려면 다음 명령을 실행합니다.

    1. sudo systemctl status mongodb_exporter.service

    출력은 서비스가 활성(실행 중)임을 확인합니다.

    ● mongodb_exporter.service - MongoDB Exporter
         Loaded: loaded (/lib/systemd/system/mongodb_exporter.service; disabled; vendor preset: enabled)
         Active: active (running) since Fri 2022-08-05 18:18:38 UTC; 1 weeks 3 days ago
       Main PID: 7352 (mongodb_exporte)
          Tasks: 5 (limit: 527)
         Memory: 14.2M
         CGroup: /system.slice/mongodb_exporter.service
                 └─7352 /usr/local/bin/mongodb_exporter
    
    

    모든 것이 예상대로 작동하는지 확인하려면 프로젝트 루트로 이동하여 내보내기가 실행되는 포트 9216에서 curl 명령을 실행합니다.

    1. cd ~
    2. sudo curl http://localhost:9216/metrics

    출력은 길며 다음과 유사한 행을 포함합니다.

    Output
    # HELP go_gc_duration_seconds A summary of the GC invocation durations. # TYPE go_gc_duration_seconds summary go_gc_duration_seconds{quantile="0"} 0 go_gc_duration_seconds{quantile="0.25"} 0 go_gc_duration_seconds{quantile="0.5"} 0 go_gc_duration_seconds{quantile="0.75"} 0 go_gc_duration_seconds{quantile="1"} 0 go_gc_duration_seconds_sum 0 go_gc_duration_seconds_count 0 # HELP go_goroutines Number of goroutines that currently exist. # TYPE go_goroutines gauge go_goroutines 11 # HELP go_memstats_alloc_bytes Number of bytes allocated and still in use. # TYPE go_memstats_alloc_bytes gauge go_memstats_alloc_bytes 1.253696e+06 # HELP go_memstats_alloc_bytes_total Total number of bytes allocated, even if freed. # TYPE go_memstats_alloc_bytes_total counter go_memstats_alloc_bytes_total 1.253696e+06 # HELP go_memstats_buck_hash_sys_bytes Number of bytes used by the profiling bucket hash table. # TYPE go_memstats_buck_hash_sys_bytes gauge go_memstats_buck_hash_sys_bytes 3054 # HELP go_memstats_frees_total Total number of frees. # TYPE go_memstats_frees_total counter go_memstats_frees_total 2866 # HELP go_memstats_gc_sys_byte . . . # HELP mongodb_asserts_total The asserts document reports the number of asserts on the database. While assert errors are typically uncommon, if there are non-zero values for the asserts, you should check the log file for the mongod process for more information. In many cases these errors are trivial, but are worth investigating. # TYPE mongodb_asserts_total counter mongodb_asserts_total{type="msg"} 0 mongodb_asserts_total{type="regular"} 0 mongodb_asserts_total{type="rollovers"} 0 mongodb_asserts_total{type="user"} 19 mongodb_asserts_total{type="warning"} 0 # HELP mongodb_connections The connections sub document data regarding the current status of incoming connections and availability of the database server. Use these values to assess the current load and capacity requirements of the server # TYPE mongodb_connections gauge mongodb_connections{state="available"} 51198 mongodb_connections{state="current"} 2 # HELP mongodb_connections_metrics_created_total totalCreated provides a count of all incoming connections created to the server. This number includes connections that have since closed # TYPE mongodb_connections_metrics_created_total counter mongodb_connections_metrics_created_total 6 # HELP mongodb_exporter_build_info A metric with a constant '1' value labeled by version, revision, branch, and goversion from which mongodb_exporter was built. # TYPE mongodb_exporter_build_info gauge mongodb_exporter_build_info{branch="v0.7.1",goversion="go1.11.10",revision="3002738d50f689c8204f70f6cceb8150b98fa869",version="0.7.1"} 1 # HELP mongodb_exporter_last_scrape_duration_seconds Duration of the last scrape of metrics from MongoDB. # TYPE mongodb_exporter_last_scrape_duration_seconds gauge mongodb_exporter_last_scrape_duration_seconds 0.003641888 # HELP mongodb_exporter_last_scrape_error Whether the last scrape of metrics from MongoDB resulted in an error (1 for error, 0 for success). # TYPE mongodb_exporter_last_scrape_error gauge mongodb_exporter_last_scrape_error 0 . . . ...

    출력은 MongoDB 내보내기가 mongodb 버전, metrics-document 및 연결 세부 정보와 같은 메트릭을 수집하고 있음을 확인합니다.

    이 섹션에서는 MongoDB 내보내기를 서비스로 설정하고 MongoDB에서 메트릭을 수집했습니다. 다음으로 내보내기를 Prometheus의 대상으로 구성합니다.

    MongoDB 내보내기를 Prometheus 대상으로 구성

    이 섹션에서는 MongoDB 내보내기를 Prometheus 대상으로 구성합니다. Prometheus 구성 파일이 있는 디렉터리로 이동합니다.

    1. cd /etc/prometheus/

    nano 또는 선호하는 텍스트 편집기를 사용하여 편집할 파일을 엽니다.

    1. sudo nano prometheus.yml

    강조 표시된 줄을 파일에 복사하여 MongoDB 내보내기를 대상으로 추가합니다.

    # A scrape configuration containing exactly one endpoint to scrape:
    # Here it's Prometheus itself.
    scrape_configs:
      # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
      - job_name: "prometheus"
        static_configs:
                - targets: ["localhost:9090", "localhost:9216"]
    

    9216은 MongoDB 내보내기의 기본 포트입니다.

    파일을 저장하고 닫습니다.

    대상을 추가한 후 Prometheus를 다시 시작합니다.

    1. sudo systemctl restart prometheus

    http://localhost:9090/targets로 이동하여 Prometheus가 새로 추가된 내보내기를 스크랩하고 있는지 확인합니다.

    참고: 원격 서버를 사용하는 경우 http://your_server_ip:9090/targets로 이동하여 대상을 볼 수 있습니다. 포트 포워딩을 사용하여 로컬에서 대상을 볼 수도 있습니다. 이렇게 하려면 로컬 컴퓨터에서 새 터미널을 열고 다음 명령을 입력합니다.

    1. ssh -L 9090:localhost:9090 your_non_root_user@your_server_ip

    서버에 연결되면 로컬 시스템의 웹 브라우저에서 http://localhost:9090/targets로 이동합니다.

    Prometheus 대상 목록에 액세스합니다.

    9090 엔드포인트는 Prometheus 자체 스크래핑입니다. 9216 엔드포인트는 구성이 예상대로 작동하는지 확인하는 MongoDB 내보내기입니다.

    이 단계에서는 MongoDB 내보내기 프로그램을 설치하고 지표를 수집하기 위해 Prometheus 대상으로 구성했습니다. 다음으로 Grafana 웹 콘솔에서 MongoDB 대시보드를 생성하여 이러한 메트릭을 보고 분석합니다.

    3단계 - Grafana에서 MongoDB 대시보드 구축

    이 단계에서는 Grafana에서 MongoDB 데이터를 시각화하는 대시보드를 구축합니다. 이를 위해 Prometheus를 Grafana의 데이터 소스로 추가하고 MongoDB 개요 대시보드에서 Grafana 인스턴스로 MongoDB 대시보드를 가져옵니다. 시작하려면 Prometheus를 Grafana 데이터 소스로 설정합니다.

    전제 조건의 일부로 Grafana를 설치하고 보호했습니다. your_domain:3000에서 Grafana 인스턴스로 이동하고 전제 조건 중에 생성한 자격 증명을 사용하여 로그인합니다.

    왼쪽 패널에서 구성의 톱니바퀴 아이콘을 클릭한 다음 데이터 소스를 선택합니다.

    데이터 소스 추가를 클릭합니다.

    그런 다음 프로메테우스를 선택합니다.

    다음 화면에서 Prometheus 데이터 소스에 대한 설정을 구성합니다.

    URL 필드에 Prometheus 인스턴스의 URL을 제공합니다.

    http://your_server_ip:9090/
    

    화면 하단의 저장 및 테스트를 클릭합니다. 이제 Prometheus가 Grafana의 데이터 소스로 추가되었습니다.

    다음으로 Grafana용 MongoDB 개요 대시보드를 가져옵니다. JSON 파일을 업로드하거나 대시보드용 Grafana 제품 문서에서 찾을 수 있는 대시보드 ID를 가져와서 대시보드를 가져올 수 있습니다. 여기에서 대시보드 ID를 사용하여 대시보드를 가져옵니다.

    왼쪽 메뉴에서 만들기에 대한 더하기 아이콘을 클릭하고 가져오기를 선택합니다. 여기에서 가져오기 페이지로 이동해야 합니다.

    여기에서 대시보드의 JSON 파일을 업로드하거나 Grafana 대시보드 ID를 붙여넣을 수 있습니다.

    MongoDB 개요 대시보드의 Grafana 페이지에서 찾을 수 있는 Grafana 대시보드 ID를 추가합니다.

    https://grafana.com/grafana/dashboards/7353
    

    많은 대시보드를 사용할 수 있습니다. 대시보드의 Grafana 페이지를 방문하면 더 많은 정보를 찾을 수 있습니다.

    대시보드 ID를 추가한 후 로드를 클릭합니다.

    이제 대시보드의 이름을 제공하고 대시보드의 폴더를 선택하고 데이터 원본을 선택할 수 있는 옵션 페이지가 열립니다. 대시보드 및 폴더 이름을 기본값으로 둘 수 있습니다. 데이터 원본으로 Prometheus를 선택합니다. 옵션을 입력했으면 가져오기를 클릭합니다.

    대시보드가 생성됩니다.

    대시보드에는 명령 작업, 연결, 커서, 문서 작업 및 대기 중인 작업을 포함하여 MongoDB 데이터베이스의 실시간 업데이트가 표시됩니다. (자세한 내용은 MongoDB 개요 대시보드에 대한 Percona 문서를 확인하세요.)

    결론

    이 기사에서는 GUI 대시보드를 통해 데이터베이스를 모니터링할 수 있는 MongoDB 데이터베이스에 대한 Prometheus 메트릭을 모니터링하도록 Grafana 대시보드를 설정합니다. 먼저 Prometheus를 설치하고 MongoDB 내보내기를 구성했습니다. 그런 다음 MongoDB 인스턴스의 데이터를 모니터링하고 시각화할 수 있는 Grafana의 데이터 소스로 Prometheus를 추가했습니다.

    이제 MongoDB에 대해 완전히 작동하는 모니터링 파이프라인이 있으므로 조금 더 자세히 알아볼 수 있습니다. 시작하려면 Grafana에서 추가 대시보드를 탐색해 보십시오.

    MongoDB에 대해 자세히 알아보려면 MongoDB 튜토리얼 시리즈로 데이터를 관리하는 방법을 확인하세요.

    완전히 작동하는 데이터베이스 환경으로 빠르게 이동하려면 DigitalOcean의 MongoDB 관리 데이터베이스를 확인하십시오.