설치 가이드 · 8 min read · Oct 09, 2025

우분투 24.04에 Grafana와 Prometheus 설치하는 방법

Grafana는 Grafana Labs에서 개발한 오픈 소스 다중 플랫폼 데이터 시각화 플랫폼입니다. Grafana는 차트, 그래프 및 알림을 포함하는 대화형 데이터 시각화 웹 애플리케이션을 제공합니다. Grafana를 사용하면 TSDB의 메트릭, 로그 및 추적을 쿼리하고 시각화하며 알림을 설정하고 탐색할 수 있습니다. 이는 시계열 데이터베이스(TSDB) 데이터를 통찰력 있는 그래프와 시각화로 변환하는 강력한 도구입니다.

Grafana에서는 ‘데이터 소스’를 통해 시계열 데이터베이스 데이터를 추가할 수 있습니다. Grafana는 Prometheus, InfluxDB, PostgreSQL, Loki, Jaeger, Graphite, Google Cloud Monitoring, AWS CloudWatch, Azure Monitor 등 여러 데이터 소스를 지원합니다.

이 튜토리얼에서는 우분투 24.04 서버에 Grafana, Prometheus 및 node_exporter를 설치하는 방법을 배웁니다. 또한 Grafana의 리버스 프록시로 Nginx를 설치하고, node_exporter와 Prometheus를 통합한 다음, Grafana 대시보드에 Prometheus를 데이터 소스로 추가합니다.

전제 조건

시작하기 전에 다음 사항을 확인하세요:

  • 두 개 또는 세 개의 우분투 24.04 서버.
  • 관리자 권한이 있는 비루트 사용자.

우분투에 Grafana 설치하기

Grafana는 데이터 시각화를 위한 웹 애플리케이션입니다. Grafana를 설치하려면 Grafana 저장소를 추가해야 합니다. 이 예제에서는 Grafana의 리버스 프록시로 Nginx도 설치합니다.

의존성 설치 및 저장소 추가

이 섹션에서는 Nginx를 포함한 의존성을 설치한 다음 Grafana 저장소를 추가합니다.

먼저, 아래 명령어를 실행하여 Grafana의 의존성을 설치합니다. 설치를 확인하려면 Y를 입력하세요.

sudo apt install gnupg2 apt-transport-https software-properties-common wget nginx

install deps

이제 다음 명령어로 Grafana GPG 키와 저장소를 추가합니다.

wget -q -O - https://packages.grafana.com/gpg.key > grafana.key cat grafana.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/grafana.gpg > /dev/null
echo ‘deb [signed-by=/etc/apt/trusted.gpg.d/grafana.gpg] https://packages.grafana.com/oss/deb stable main’ | sudo tee /etc/apt/sources.list.d/grafana.list

그런 다음 아래 명령어로 패키지 인덱스를 업데이트하고 새로 고칩니다:

sudo apt update

add repo and update

Grafana 설치 및 구성

Grafana 저장소를 추가한 후, APT 패키지 관리자를 사용하여 Grafana 패키지를 설치합니다. 그런 다음 howtoforge.local과 같은 도메인으로 localhost에서 Grafana를 실행하도록 구성합니다.

Grafana를 설치하려면 다음 apt 명령어를 실행합니다. 설치를 진행하려면 Y를 입력하세요.

sudo apt install grafana

install grafana

설치가 완료되면 아래 명령어로 systemd 관리자를 다시 로드합니다:

sudo systemctl daemon-reload

이제 다음 systemctl 명령어로 grafana-server를 시작하고 활성화할 수 있습니다. 그런 다음 서비스가 실행 중인지 확인합니다.

sudo systemctl enable --now grafana-server  
sudo systemctl status grafana-server

다음 출력에서 grafana-server가 실행 중이고 활성화되어 있는 것을 볼 수 있습니다.

start enable verify grafana

grafana-server가 실행 중인 상태에서, 이를 localhost에서 실행하도록 구성합니다.

nano 편집기로 Grafana 구성 파일 /etc/grafana/grafana.ini를 엽니다.

sudo nano /etc/grafana/grafana.ini

기본 구성을 다음과 같이 변경합니다. Grafana의 로컬 도메인 이름으로 domain 옵션을 변경해야 합니다. 이 예제에서는 howtoforge.local 도메인 내에서 Grafana를 실행합니다.

[server]

# The IP address to bind to, empty will bind to all interfaces
http_addr = localhost

# The http port  to use
http_port = 3000

# The public facing domain name used to access grafana from a browser
domain = howtoforge.local

완료되면 파일을 저장하고 편집기를 종료합니다.

이제 아래 명령어를 실행하여 grafana-server를 재시작하고 변경 사항을 적용합니다. 이로써 Grafana는 기본 HTTP 포트 3000에서 localhost에서 실행되어야 합니다.

sudo systemctl restart grafana-server

Nginx를 리버스 프록시로 설정하기

이 섹션에서는 localhost에서 포트 3000으로 실행 중인 grafana-server의 리버스 프록시로 새로운 Nginx 서버 블록을 생성합니다.

nano 편집기로 새로운 Nginx 서버 블록 구성 파일 /etc/nginx/sites-available/grafana.conf를 생성합니다.

sudo nano /etc/nginx/sites-available/grafana.conf

다음 구성을 추가하여 Grafana의 리버스 프록시로 Nginx를 설정합니다. Grafana 도메인 이름으로 server_name 옵션을 변경해야 합니다.

# this is required to proxy Grafana Live WebSocket connections.
map $http_upgrade $connection_upgrade {
  default upgrade;
  '' close;
}

server {
    listen      80;
    server_name howtoforge.local;

  root /usr/share/nginx/html;
  index index.html index.htm;


  access_log /var/log/nginx/grafana-access.log;
  error_log /var/log/nginx/grafana-error.log;

  location / {
    proxy_set_header Host $http_host;
    proxy_pass http://localhost:3000/;
  }

  # Proxy Grafana Live WebSocket connections.
  location /api/live {
    rewrite  ^/(.*)  /$1 break;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $http_host;
    proxy_pass http://localhost:3000/;
  }
}

파일을 저장하고 편집기를 종료합니다.

이제 다음 명령어를 실행하여 grafana.conf 서버 블록을 활성화하고 Nginx 구문을 확인합니다. 구문이 올바르면 test is Successful - syntax is OK라는 출력이 표시됩니다.

sudo ln -s /etc/nginx/sites-available/grafana.conf /etc/nginx/sites-enabled/  
sudo nginx -t

setup nginx

다음으로, 아래 systemctl 명령어를 실행하여 Nginx 웹 서버를 재시작하고 상태를 확인합니다.

sudo systemctl restart nginx  
sudo systemctl status nginx

Nginx 웹 서버가 실행 중인 것을 확인할 수 있습니다:

check nginx

다음으로, http://howtoforge.local/와 같은 Grafana 도메인 이름을 방문합니다. 설치가 성공적이라면 Grafana 로그인 페이지가 표시됩니다.

기본 사용자 admin과 비밀번호 admin으로 로그인합니다.

login grafana

로그인 후, Grafana 설치를 위한 새 비밀번호를 입력하고 제출을 클릭하여 확인합니다.

change password

다음과 같은 Grafana 대시보드를 볼 수 있습니다:

dashboard

Prometheus 설치 및 구성

Prometheus는 모니터링 및 알림 플랫폼입니다. Grafana가 실행 중인 상태에서, 192.168.5.16 서버에 Prometheus를 설치합니다.

Prometheus 설치하기

이 섹션에서는 Prometheus의 바이너리를 시스템에 다운로드하여 수동으로 설치합니다. 그 전에 새로운 시스템 사용자 prometheus를 생성합니다.

먼저, 아래 명령어를 실행하여 새로운 사용자 및 그룹 prometheus를 추가합니다.

sudo groupadd --system prometheus  
sudo useradd -s /sbin/nologin --system -g prometheus prometheus

새 데이터 디렉토리 /var/lib/prometheus와 구성 디렉토리 /etc/prometheus를 생성합니다.

sudo mkdir -p /var/lib/prometheus  
for i in rules rules.d files_sd; do sudo mkdir -p /etc/prometheus/${i}; done

다음 명령어로 리눅스용 Prometheus 최신 버전을 다운로드합니다.

curl -s https://api.github.com/repos/prometheus/prometheus/releases/latest|grep browser_download_url|grep linux-amd64|cut -d ‘"’ -f 4|wget -qi -

다운로드가 완료되면 tar 명령어로 Prometheus 바이너리 파일을 추출하고 해당 디렉토리로 이동합니다.

tar xvf prometheus*.tar.gz  
cd prometheus*/

바이너리 파일 prometheuspromtool/usr/local/bin 디렉토리로 이동합니다. 그런 다음 구성 디렉토리와 파일 prometheus.yml/etc/prometheus 디렉토리로 이동합니다.

sudo mv prometheus promtool /usr/local/bin/  
sudo mv consoles console_libraries prometheus.yml /etc/prometheus/

마지막으로, 아래 명령어를 실행하여 Prometheus 구성 및 데이터 디렉토리의 권한과 소유권을 사용자 prometheus로 변경합니다.

for i in rules rules.d files_sd; do sudo chown -R prometheus:prometheus /etc/prometheus/${i}; done  
for i in rules rules.d files_sd; do sudo chmod -R 775 /etc/prometheus/${i}; done  
sudo chown -R prometheus:prometheus /var/lib/prometheus/

Prometheus 구성하기

Prometheus를 설치한 후, basic_auth 또는 기본 인증을 사용하여 Prometheus를 보호합니다.

다음 apt 명령어로 apache2-utils 패키지를 설치합니다.

sudo apt install apache2-utils -y

install apache2-utils

이제 아래 htpasswd 명령어를 실행하여 사용자 admin의 bcrypt 비밀번호를 생성합니다. 비밀번호를 입력하고 반복한 다음, 생성된 비밀번호를 복사합니다.

htpasswd -nB admin

다음으로, 아래 nano 명령어를 실행하여 새로운 파일 /etc/prometheus/web.yml을 생성합니다.

sudo nano /etc/prometheus/web.yml

다음 구성을 추가하고 아래의 bcrypt 비밀번호를 변경해야 합니다.

# basic_auth
basic_auth_users:
  admin: $2y$05$s8U/BrE5JhSO31XKSbtj8u8cPECULs3emEhlDfCB2GW1UefQ9x00C

완료되면 파일을 저장하고 종료합니다.

이제 기본 Prometheus 구성 파일 /etc/prometheus/prometheus.ymlnano로 엽니다.

sudo nano /etc/prometheus/prometheus.yml

기본 job_name을 다음과 같이 변경하고 basic_auth 사용자와 비밀번호를 변경해야 합니다.

scrape_configs:
  # The job name is added as a label `job=` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.
    # add settings for certificate and authentication
    scheme: http
    basic_auth:
      username: "admin"
      password: "password"

    static_configs:
      # if using a valid certificate, set the same hostname in the certificate
      - targets: ["localhost:9090"]

파일을 저장하고 종료합니다.

마지막으로, 아래 명령어를 실행하여 파일 prometheus.ymlweb.yml의 소유권을 사용자 prometheus로 변경합니다.

sudo chown prometheus: /etc/prometheus/{prometheus.yml,web.yml}

Prometheus를 systemd 서비스로 실행하기

새로운 systemd 서비스 파일 /etc/systemd/system/prometheus.service를 다음 nano 편집기로 생성합니다.

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

다음 줄을 파일에 추가합니다. 이를 통해 Prometheus를 백그라운드에서 systemd 서비스로 실행하고 web.yml 파일을 통해 웹 콘솔을 보호합니다.

[Unit]
Description=Prometheus
Documentation=https://prometheus.io/docs/introduction/overview/
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=prometheus
Group=prometheus
ExecReload=/bin/kill -HUP $MAINPID
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 \
 --web.config.file=/etc/prometheus/web.yml \

SyslogIdentifier=prometheus
Restart=always

[Install]
WantedBy=multi-user.target

파일을 저장하고 편집기를 종료합니다.

이제 아래 명령어를 실행하여 systemd 관리자를 다시 로드하고 변경 사항을 적용합니다.

sudo systemctl daemon-reload

configure prometheus

그런 다음 아래 systemctl 명령어를 사용하여 prometheus 서비스를 시작하고 활성화하며 서비스가 실행 중인지 확인합니다.

sudo systemctl enable --now prometheus  
sudo systemctl status prometheus

다음 출력에서 prometheus 서비스가 실행 중이고 활성화되어 있는 것을 볼 수 있습니다.

check prometheus

node_exporter 설치하기

이제 Grafana와 Prometheus가 실행 중이므로 node_exporter를 다운로드하고 설치합니다. node_exporter는 기본 시스템 모니터링을 위한 데이터를 수집할 수 있게 해줍니다.

아래 curl 명령어로 node_exporter 바이너리 파일을 다운로드합니다.

curl -s https://api.github.com/repos/prometheus/node_exporter/releases/latest| grep browser_download_url|grep linux-amd64|cut -d ‘"’ -f 4|wget -qi -

다운로드가 완료되면 node_exporter를 추출하고 해당 디렉토리로 이동합니다.

tar -xvf node_exporter*.tar.gz cd node_exporter*/

이제 node_exporter 바이너리 파일을 /usr/local/bin 디렉토리로 복사합니다.

sudo cp node_exporter /usr/local/bin

그 후, 아래 명령어를 실행하여 node_exporter를 위한 새로운 systemd 서비스 파일 /etc/systemd/system/node_exporter.service를 생성합니다.

sudo tee /etc/systemd/system/node_exporter.service <

install node exporter

다음으로, 아래 명령어로 systemd 관리자를 다시 로드합니다:

sudo systemctl daemon-reload

이제 아래 명령어로 node_exporter 서비스를 시작하고 활성화할 수 있습니다. 그런 다음 node_exporter 서비스 상태를 확인합니다.

sudo systemctl enable --now node_exporter sudo systemctl status node_exporter

node_exporter 서비스가 실행 중이며 데이터를 수집하고 채우기 시작하는 것을 볼 수 있습니다. node_exporter 서비스는 기본 포트 9100에서 실행됩니다.

start check node_exporter

node_exporter를 Prometheus에 통합하기

이 섹션에서는 node_exporter를 Prometheus에 통합하고 추가합니다.

기본 Prometheus 구성 파일 /etc/prometheus/prometheus.yml을 엽니다.

sudo nano /etc/prometheus/prometheus.yml

새로운 job_namenode_exporter로 추가하고 target192.168.5.16:9100으로 지정합니다.

  - job_name: "node_exporter"

    static_configs:
      - targets: ["192.168.5.100:9100"]

완료되면 파일을 저장하고 종료합니다.

이제 아래 명령어를 실행하여 prometheus 서비스를 재시작하고 변경 사항을 적용합니다.

sudo systemctl restart prometheus

다음으로, 웹 브라우저를 통해 Prometheus 서버 http://192.168.5.16:9090에 접속하면 기본 인증을 요청받습니다.

사용자 이름과 비밀번호를 입력하고 로그인을 클릭합니다.

Log in prometheus

Prometheus 대시보드에 로그인한 후, 쿼리에 node_memory_Active_bytes를 입력하고 실행을 클릭합니다. 현재 활성 메모리의 그래프를 볼 수 있습니다:

prometheus dashboard

마지막으로, 상태 > 대상을 클릭하여 prometheusnode_exporter 대상이 활성화되고 실행 중인지 확인합니다:

list targets

Grafana에 Prometheus를 데이터 소스로 통합하기

이제 Prometheus가 준비되었으므로 Grafana에 데이터 소스로 Prometheus를 추가하고 통합합니다. 그런 다음 모니터링을 위한 새로운 대시보드 시스템을 생성합니다.

Grafana 대시보드 내에서 연결 > 데이터 소스 > 데이터 소스 추가를 클릭하여 Grafana에 새로운 데이터 소스를 추가합니다.

add data source

데이터 소스로 Prometheus를 선택합니다.

prometheus

Prometheus URL을 http://192.168.5.16:9090/로 입력하고 Prometheus 서버의 사용자 이름과 비밀번호를 입력합니다.

add prometheus details

아래로 스크롤하여 저장 및 테스트를 클릭합니다. 성공하면 Successfully queried the Prometheus API라는 메시지가 표시됩니다.

save and test data source

Prometheus를 데이터 소스로 추가한 후, 시스템 모니터링을 위한 새로운 Grafana 대시보드를 생성합니다.

메뉴에서 대시보드 > 대시보드 생성을 클릭합니다.

create dashboard

대시보드 가져오기를 선택하여 대시보드를 가져옵니다.

import dashboard

https://grafana.com/grafana/dashboards/를 방문하여 적합한 대시보드를 찾습니다. 이 예제에서는 ID가 15172인 Grafana 대시보드를 로드합니다.

로드를 클릭하여 대시보드를 가져옵니다.

Load dashboard id

이제 Prometheus 백엔드를 선택하고 가져오기를 클릭하여 확인합니다.

select prometheus as backend

모든 것이 잘 진행되면 Grafana 대시보드가 생성되어야 합니다. 아래는 Prometheus와 node_exporter 모니터링이 포함된 Grafana 대시보드의 스크린샷입니다:

dashboard monitoring

결론

축하합니다! 우분투 24.04 서버에 Grafana, Prometheus 및 node_exporter 설치를 완료했습니다. Nginx를 리버스 프록시로 사용하여 Grafana가 실행되고, 비밀번호 인증으로 Prometheus가 보호되며, node_exporter가 Prometheus와 통합되고, Prometheus가 Grafana에 데이터 소스로 추가되었으며, Grafana 대시보드가 가져와졌습니다.

Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.