카테고리 없음

Azure에서 Prometheus 설치 방법

idea9329 2025. 3. 6. 10:59
반응형

 

Azure에서 Prometheus를 설치하여 모니터링 시스템을 구축하는 방법을 단계별로 설명하겠습니다.
Prometheus는 Azure Kubernetes Service(AKS) 또는 Azure Virtual Machine(VM)에서 실행할 수 있으며, 일반적으로 AKS에서 사용됩니다.


1️⃣ Azure Kubernetes Service(AKS)에서 Prometheus 설치

Azure Kubernetes Service(AKS)에서 Prometheus를 설치하는 방법을 설명합니다.
Helm을 사용하여 빠르게 배포할 수 있습니다.

✅ 1. AKS 클러스터 생성 (이미 있다면 건너뛰기)

az aks create --resource-group <ResourceGroup> \
  --name <ClusterName> \
  --node-count 3 \
  --enable-managed-identity \
  --enable-addons monitoring \
  --generate-ssh-keys
  • <ResourceGroup> : 리소스 그룹 이름
  • <ClusterName> : AKS 클러스터 이름
  • --node-count 3 : 노드 개수 (최소 3개 추천)

✅ 2. Helm 설치 및 Prometheus 차트 추가

Helm이 설치되어 있지 않다면 먼저 설치합니다.

curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

Prometheus Helm 차트를 추가합니다.

helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update

✅ 3. Prometheus 및 Grafana 설치

Prometheus와 Grafana를 한 번에 배포합니다.

helm install prometheus prometheus-community/kube-prometheus-stack \
  --namespace monitoring --create-namespace
  • --namespace monitoring : Prometheus를 위한 별도 네임스페이스 생성
  • kube-prometheus-stack : Prometheus + Grafana + Alertmanager 포함

✅ 4. Prometheus 서비스 확인

설치가 완료되면 서비스가 정상적으로 실행되고 있는지 확인합니다.

kubectl get pods -n monitoring
kubectl get svc -n monitoring

✅ 5. Prometheus 대시보드 접속

Prometheus 웹 UI에 접근하기 위해 포트포워딩을 설정합니다.

kubectl port-forward -n monitoring svc/prometheus-kube-prometheus-prometheus 9090

이후, 웹 브라우저에서 http://localhost:9090 로 접속하면 Prometheus UI를 확인할 수 있습니다.

Grafana도 실행하려면 아래 명령어를 사용합니다.

kubectl port-forward -n monitoring svc/prometheus-grafana 3000

이후 http://localhost:3000 에 접속하여 Grafana를 사용할 수 있습니다.
기본 로그인 정보:

  • Username: admin
  • Password: prom-operator (기본값, 변경 가능)

2️⃣ Azure Virtual Machine에서 Prometheus 설치

AKS가 아닌 Azure Virtual Machine에 Prometheus를 직접 설치하는 방법입니다.

✅ 1. VM 생성 및 접속

az vm create --resource-group <ResourceGroup> \
  --name <VMName> \
  --image Ubuntu2204 \
  --admin-username azureuser \
  --generate-ssh-keys
  • <ResourceGroup> : 리소스 그룹 이름
  • <VMName> : 생성할 VM 이름
  • Ubuntu 22.04 LTS를 사용 (다른 버전도 가능)

VM에 SSH로 접속합니다.

ssh azureuser@<VM_Public_IP>

✅ 2. Prometheus 설치

sudo apt update && sudo apt install -y prometheus

Prometheus 서비스가 정상적으로 실행되는지 확인합니다.

systemctl status prometheus

✅ 3. Prometheus 웹 UI 접속

기본 포트 9090에서 실행됩니다.
Azure 포털에서 네트워크 보안 그룹(NSG)을 설정하여 포트 9090을 허용한 후, 브라우저에서 http://<VM_Public_IP>:9090로 접속하면 됩니다.


3️⃣ Prometheus + Azure Monitor 연동 (선택)

Azure에서 제공하는 Azure Monitor와 Prometheus를 연동하여 클라우드 기반 모니터링을 강화할 수도 있습니다.

✅ 1. Azure Monitor에 Prometheus 데이터 보내기

Azure Monitor의 Managed Prometheus 기능을 사용하면 Prometheus 데이터를 자동으로 수집할 수 있습니다.

az monitor log-analytics workspace create \
  --resource-group <ResourceGroup> \
  --workspace-name <WorkspaceName>
  • <WorkspaceName> : Azure Log Analytics 워크스페이스 이름

이후, prometheus.yml 파일을 수정하여 Azure Monitor로 데이터 전송할 수 있습니다.

remote_write:
  - url: https://<AzureMonitorEndpoint>/api/v1/write
    bearer_token: <AzureMonitorAuthToken>

🚀 결론

 Azure Kubernetes Service(AKS)에서 Prometheus를 설치하는 경우, Helm을 사용하면 빠르게 구축 가능
 Azure Virtual Machine에서 설치하는 경우, apt install을 통해 직접 설정 가능
 Azure Monitor와 연동하면 Prometheus 데이터를 Azure에서 모니터링 가능

어떤 환경에서 실행할지에 따라 적절한 방법을 선택하면 됩니다. 🎯

반응형