Azure Monitor 데이터 소스 구성
Azure Monitor 데이터 소스 구성 (Configure the Azure Monitor data source)
이 문서는 Azure Monitor 데이터 소스를 구성하는 방법과 사용 가능한 구성 옵션을 설명해요. Azure Monitor 데이터 소스 플러그인은 Grafana에 내장되어 있어 추가 설치가 필요 없어요.
출처: 문서
본문
시작 전에
Azure 구독과 해당 구독에 대한 접근 권한, 그리고 인증 방법에 필요한 자격 증명이 있어야 해요.
참고: Grafana Cloud 사용자: Managed Identity와 Workload Identity 인증 방법은 Grafana가 여러분의 Azure 인프라에서 실행돼야 하므로 Grafana Cloud에서는 사용할 수 없어요. 대신 App Registration 인증을 사용하세요.
인증 방법 선택
Azure Monitor 데이터 소스는 다섯 가지 인증 방법을 지원해요. Grafana가 호스팅되는 위치, 보안 요구 사항, 알림 필요 여부에 따라 선택하세요.
| 인증 방법 | 가장 적합 | Grafana Cloud | 알림 지원 | 서버 구성 필요 |
|---|---|---|---|---|
| App Registration (client secret) | 모든 Grafana 배포 | ✓ | ✓ | 아니오 |
| App Registration (client certificate) | 모든 Grafana 배포 | ✓ | ✓ | 아니오 |
| Managed Identity | Azure에 호스팅된 Grafana (VM, App Service) | ✗ | ✓ | 예 |
| Workload Identity | Kubernetes(AKS)의 Grafana | ✗ | ✓ | 예 |
| Current User | 사용자 수준 접근 제어 | ✓ | 부분 | 예 |
참고: Current User 인증은 알림, 보고, recording rules 같은 백그라운드 작업을 지원하지 않아요. Current User로 알림을 사용하려면 fallback service credentials을 구성해야 해요. 그러면 알림이 fallback 자격 증명의 권한으로 실행돼요.
인증 구성
App Registration (client secret)
Microsoft Entra ID 앱 등록(서비스 주체)으로 인증해요. 모든 Grafana 배포에서 동작해요. UI 구성 설정:
| 설정 | 설명 |
|---|---|
| Authentication | App Registration 선택 |
| Azure Cloud | 연결할 Azure 환경. 공용 클라우드는 Azure, 국가 클라우드는 Azure Government 또는 Azure China 선택 |
| Directory (tenant) ID | Microsoft Entra ID 테넌트를 식별하는 GUID |
| Application (client) ID | 만든 앱 등록의 GUID |
| Client secret | 앱 등록의 시크릿 키. 안전하게 보관하고 주기적으로 교체 |
| Default Subscription | Load Subscriptions를 클릭해 사용 가능한 구독을 채운 뒤 기본값 선택 |
YAML 프로비저닝:
apiVersion: 1
datasources:
- name: Azure Monitor
type: grafana-azure-monitor-datasource
access: proxy
jsonData:
azureAuthType: clientsecret
cloudName: azuremonitor # See supported cloud names below
tenantId: <tenant-id>
clientId: <client-id>
subscriptionId: <subscription-id> # Optional, default subscription
secureJsonData:
clientSecret: <client-secret>
version: 1
App Registration (client certificate)
인증서가 있는 Microsoft Entra ID 앱 등록을 사용해요. Azure 포털의 앱 등록에 공개 인증서를 추가하며, 업로드된 인증서는 Microsoft Entra ID가 Grafana의 클라이언트 어서션 서명을 검증하는 데 사용돼요.
지원되는 인증서 형식: PEM, PFX.
자가 서명 인증서 생성 예시(테스트/랩 환경용. 프로덕션은 내부 또는 공개 인증 기관 사용):
openssl genrsa -out key.pem 2048
openssl req -new -sha256 -key key.pem -out csr.csr
openssl req -x509 -sha256 -days 365 -key key.pem -in csr.csr -out certificate.pem
암호화된 base64 인코딩 PFX 인증서 생성:
openssl genrsa -out key.pem 2048
openssl req -new -sha256 -key key.pem -out csr.csr
openssl req -x509 -sha256 -days 365 -key key.pem -in csr.csr -out certificate.pem
openssl pkcs12 -export -inkey key.pem -in certificate.pem -out certificate.pfx
openssl base64 -in certificate.pfx -out certificate.b64
인증서를 암호화하는 데 사용한 비밀번호를 반드시 기록해 두세요.
UI 구성 설정:
| 설정 | 설명 |
|---|---|
| Authentication | App Registration (Client Certificate) 선택 |
| Azure Cloud | 연결할 Azure 환경 |
| Directory (tenant) ID | Microsoft Entra ID 테넌트 GUID |
| Application (client) ID | 만든 앱 등록의 GUID |
| Format | PEM 또는 PFX 선택 |
| Client Certificate | 인증서 내용 붙여넣기 (PEM 텍스트 또는 base64 인코딩 PFX 페이로드) |
| Private Key | PEM에서만 필요. 프라이빗 키 PEM 붙여넣기 |
| Certificate Password | 암호화된 PFX 파일에 필요 |
| Default Subscription | Load Subscriptions 클릭 후 기본값 선택 |
YAML 프로비저닝 (client certificate):
apiVersion: 1
datasources:
- name: Azure Monitor
type: grafana-azure-monitor-datasource
access: proxy
jsonData:
azureAuthType: clientcertificate
cloudName: azuremonitor # See supported cloud names below
tenantId: <tenant-id>
clientId: <client-id>
certificateFormat: pem # Use pem or pfx
subscriptionId: <subscription-id> # Optional, default subscription
secureJsonData:
clientCertificate: <certificate-content>
privateKey: <private-key-content> # pem only
certificatePassword: <certificate-password> # pfx only, if set
version: 1
Managed Identity
Grafana가 Azure에 호스팅될 때 자격 증명 없는 보안 인증에 Azure Managed Identity를 사용해요.
참고: Managed Identity는 Azure Managed Grafana 또는 Azure에 배포된 자체 관리 Grafana에서 사용할 수 있어요. Grafana Cloud에서는 사용할 수 없어요.
Grafana 서버 구성에서 관리 ID 활성화:
[azure]
managed_identity_enabled = true
시스템 할당 ID 대신 사용자 할당 관리 ID를 사용하려면:
[azure]
managed_identity_enabled = true
managed_identity_client_id = <USER_ASSIGNED_IDENTITY_CLIENT_ID>
주의:
[azure]아래의forward_settings_to_plugins설정을 커스터마이즈했다면grafana-azure-monitor-datasource가 포함되어 있는지 확인하세요. 이 설정은 Grafana 서버에서 Azure 구성을 받는 플러그인을 제어해요. 기본적으로 모든 Grafana Labs Azure 플러그인이 포함돼요. 이 설정이 없으면 Azure 리소스에 Managed Identity가 올바르게 구성됐어도 401 Unauthorized 오류가 발생해요.
UI 구성 설정:
| 설정 | 설명 |
|---|---|
| Authentication | Managed Identity 선택. 디렉터리 ID, 애플리케이션 ID, client secret 필드는 숨겨짐 |
| Default Subscription | Load Subscriptions 클릭 후 기본값 선택 |
YAML 프로비저닝:
apiVersion: 1
datasources:
- name: Azure Monitor
type: grafana-azure-monitor-datasource
access: proxy
jsonData:
azureAuthType: msi
subscriptionId: <subscription-id> # Optional, default subscription
version: 1
Workload Identity
AKS 같은 Kubernetes 환경에서 보안 인증에 Azure Workload Identity를 사용해요.
Grafana 서버 구성에서 활성화:
[azure]
workload_identity_enabled = true
선택적 구성 변수:
[azure]
workload_identity_enabled = true
workload_identity_tenant_id = <IDENTITY_TENANT_ID> # Microsoft Entra ID tenant containing the managed identity
workload_identity_client_id = <IDENTITY_CLIENT_ID> # Client ID if different from default
workload_identity_token_file = <TOKEN_FILE_PATH> # Path to the token file
UI 구성 설정:
| 설정 | 설명 |
|---|---|
| Authentication | Workload Identity 선택. 디렉터리 ID, 애플리케이션 ID, client secret 필드는 숨겨짐 |
| Default Subscription | Load Subscriptions 클릭 후 기본값 선택 |
YAML 프로비저닝:
apiVersion: 1
datasources:
- name: Azure Monitor
type: grafana-azure-monitor-datasource
access: proxy
jsonData:
azureAuthType: workloadidentity
subscriptionId: <subscription-id> # Optional, default subscription
version: 1
Current User
로그인한 Grafana 사용자의 Azure 자격 증명을 데이터 소스로 전달해 사용자 수준 접근 제어를 구현해요.
참고: Current User 인증은 일반 공개(GA) 기능이에요. Grafana Cloud에서 활성화하려면 Grafana 지원팀에 문의하세요.
시작 전에: Grafana 인스턴스가 Microsoft Entra ID 인증으로 구성되어 있어야 해요. Grafana 로그인에 사용하는 App Registration에는 토큰 발급 활성화와 API 권한 추가 같은 추가 구성이 필요해요. Grafana 스코프를 업데이트해 .default 스코프를 포함하세요:
.default openid email profile
Grafana 서버 구성에서 활성화:
[azure]
user_identity_enabled = true
기본적으로 fallback 서비스 자격 증명도 활성화돼요. 인스턴스 수준에서 fallback 자격 증명을 비활성화하려면:
[azure]
user_identity_enabled = true
user_identity_fallback_credentials_enabled = false
제한 사항과 fallback 자격 증명: Current User 인증은 사용자 자격 증명이 백그라운드 작업에 사용할 수 없으므로 알림, 보고, 기록된 쿼리 같은 백엔드 기능을 지원하지 않아요. 이 기능을 지원하려면 일반적으로 client secret이 있는 App Registration인 fallback service credentials를 구성해야 해요. 활성화하면 Grafana는 백엔드 작업에 fallback 자격 증명을 사용하며, fallback 자격 증명으로 수행하는 작업은 사용자 권한이 아니라 그 자격 증명의 권한으로 제한돼요.
주의: fallback 서비스 자격 증명 없이 Current User 인증을 사용하면 알림 규칙, recording rules, 보고서가 인증 오류로 실패해요.
참고: Current User 인증을 사용하는 데이터 소스는 기본적으로 쿼리·리소스 캐싱이 비활성화돼요.
UI 구성 설정:
| 설정 | 설명 |
|---|---|
| Authentication | Current User 선택 |
| Default Subscription | Load Subscriptions 클릭 후 기본값 선택 |
| Fallback Service Credentials | 알림 같은 백엔드 기능용 자격 증명 활성화 및 구성 |
YAML 프로비저닝:
apiVersion: 1
datasources:
- name: Azure Monitor
type: grafana-azure-monitor-datasource
access: proxy
jsonData:
azureAuthType: currentuser
oauthPassThru: true
disableGrafanaCache: true
subscriptionId: <subscription-id> # Optional, default subscription
version: 1
참고: Current User 인증에는
oauthPassThru속성이 필요해요.disableGrafanaCache는 사용자가 접근 권한이 없는 리소스에 대해 캐시된 응답을 반환하지 않도록 방지해요.
추가 구성 옵션
이 설정은 모든 인증 방법에 적용돼요.
- 일반 설정: Name(패널과 쿼리에서 쓰는 데이터 소스 이름, 예:
azure-monitor-prod), Default(새 패널의 기본 데이터 소스로 만들기 토글). - Query timeout: 기본 데이터 소스 타임아웃은 30초예요. Azure Log Analytics 쿼리는 복잡한 KQL, 긴 시간 범위, 여러 워크스페이스 쿼리 시 Azure 쪽에서 최대 3분까지 걸릴 수 있어요. 쿼리에서
DatasourceError,context deadline exceeded,timeout오류로 실패하면 타임아웃을 늘리세요.주의: 이 타임아웃은 알림 평가에도 영향을 줘요. 30초를 초과하는 Log Analytics 쿼리를 쓰는 알림 규칙이 있으면 이 설정을 늘리지 않으면 알림 평가가 타임아웃 오류로 실패해요. 알림의 경우 평가 간격이 쿼리 지속 시간을 수용할 만큼 긴지도 확인하세요. 프로비저닝 파일에서 타임아웃을 설정하려면
jsonData섹션에timeout을 추가하세요:datasources: - name: Azure Monitor type: grafana-azure-monitor-datasource access: proxy jsonData: timeout: 300 - Enable Basic Logs: 지원되는 Log Analytics 워크스페이스의 Basic Logs 테이블에 대한 쿼리를 허용하는 토글. Basic Logs 테이블 쿼리는 쿼리당 추가 비용이 발생해요.
- Enable Batch API: Azure Monitor Metrics Batch API를 사용해 여러 리소스의 메트릭을 단일 요청으로 쿼리하는 토글. 리소스별 요청을 보내는 대신 Grafana가 적격 메트릭 쿼리를 그룹화해 함께 보내요. Azure 호출 수가 줄어 쿼리 성능이 향상되고 많은 리소스를 쿼리하는 대시보드에서 스로틀링 가능성이 낮아져요.
참고: 이 설정은
datasources.azureMonitorBatchAPI기능 토글이 활성화된 경우에만 사용할 수 있어요. Batch API 요청은metrics.monitor.azure.com데이터 플레인 엔드포인트로 보내지므로, 사용하려면 구독 범위에서 Monitoring Reader 역할이 필요해요. Metrics Batch API에는 월별 무료 허용량이 있고 이후 호출에는 비용이 발생해요. - Private data source connect (Grafana Cloud만): 프라이빗 네트워크의 Azure 리소스에 연결하려면 PDC를 사용하세요.
- Exemplars 구성: Azure Monitor 메트릭을 트레이싱 데이터 소스의 트레이스에 연결할 수 있어요. 구성 후에는 지원되는 Azure Monitor 메트릭 시각화에 exemplar 링크가 나타나 트레이싱 데이터 소스의 해당 트레이스로 이동할 수 있어요.
지원되는 클라우드 이름
프로비저닝 시 다음 cloudName 값을 사용하세요:
| Azure Cloud | cloudName 값 |
|---|---|
| Microsoft Azure 공용 클라우드 | azuremonitor (기본값) |
| Microsoft 중국 국가 클라우드 | chinaazuremonitor |
| US Government 클라우드 | govazuremonitor |
참고: Current User 인증의 클라우드 이름은 다릅니다: 공용 클라우드는
AzureCloud, 중국 국가 클라우드는AzureChinaCloud, US Government 클라우드는AzureUSGovernment.
연결 확인
구성 후 Save & test를 클릭하세요. 성공적인 연결은 자격 증명이 유효하고 구성된 기본 구독에 접근 권한이 있다는 메시지를 표시해요. 테스트가 실패하면 자격 증명, 구독 권한, 네트워크 연결을 확인하세요.
Terraform으로 구성
Grafana Terraform 프로바이더를 사용해 Azure Monitor 데이터 소스를 구성할 수 있어요. 프로바이더 구성 예시:
terraform {
required_providers {
grafana = {
source = "grafana/grafana"
version = ">= 2.0.0"
}
}
}
# For Grafana Cloud
provider "grafana" {
url = "<YOUR_GRAFANA_CLOUD_STACK_URL>"
auth = "<YOUR_SERVICE_ACCOUNT_TOKEN>"
}
# For self-managed Grafana
# provider "grafana" {
# url = "http://localhost:3000"
# auth = "<API_KEY_OR_SERVICE_ACCOUNT_TOKEN>"
# }
App Registration (client secret):
resource "grafana_data_source" "azure_monitor" {
type = "grafana-azure-monitor-datasource"
name = "Azure Monitor"
json_data_encoded = jsonencode({
azureAuthType = "clientsecret"
cloudName = "azuremonitor"
tenantId = "<TENANT_ID>"
clientId = "<CLIENT_ID>"
subscriptionId = "<SUBSCRIPTION_ID>"
})
secure_json_data_encoded = jsonencode({
clientSecret = "<CLIENT_SECRET>"
})
}
App Registration (PEM 클라이언트 인증서):
resource "grafana_data_source" "azure_monitor" {
type = "grafana-azure-monitor-datasource"
name = "Azure Monitor"
json_data_encoded = jsonencode({
azureAuthType = "clientcertificate"
cloudName = "azuremonitor"
tenantId = "<TENANT_ID>"
clientId = "<CLIENT_ID>"
certificateFormat = "pem"
subscriptionId = "<SUBSCRIPTION_ID>"
})
secure_json_data_encoded = jsonencode({
clientCertificate = "<CERTIFICATE_CONTENT>"
privateKey = "<PRIVATE_KEY_CONTENT>"
})
}
App Registration (PFX 클라이언트 인증서):
resource "grafana_data_source" "azure_monitor" {
type = "grafana-azure-monitor-datasource"
name = "Azure Monitor"
json_data_encoded = jsonencode({
azureAuthType = "clientcertificate"
cloudName = "azuremonitor"
tenantId = "<TENANT_ID>"
clientId = "<CLIENT_ID>"
certificateFormat = "pfx"
subscriptionId = "<SUBSCRIPTION_ID>"
})
secure_json_data_encoded = jsonencode({
clientCertificate = "<CERTIFICATE_CONTENT_BASE64_ENCODED>"
certificatePassword = "<CERTIFICATE_PASSWORD>"
})
}
Managed Identity:
resource "grafana_data_source" "azure_monitor" {
type = "grafana-azure-monitor-datasource"
name = "Azure Monitor"
json_data_encoded = jsonencode({
azureAuthType = "msi"
subscriptionId = "<SUBSCRIPTION_ID>"
})
}
Workload Identity:
resource "grafana_data_source" "azure_monitor" {
type = "grafana-azure-monitor-datasource"
name = "Azure Monitor"
json_data_encoded = jsonencode({
azureAuthType = "workloadidentity"
subscriptionId = "<SUBSCRIPTION_ID>"
})
}
Current User:
resource "grafana_data_source" "azure_monitor" {
type = "grafana-azure-monitor-datasource"
name = "Azure Monitor"
json_data_encoded = jsonencode({
azureAuthType = "currentuser"
oauthPassThru = true
disableGrafanaCache = true
subscriptionId = "<SUBSCRIPTION_ID>"
})
}
Basic Logs 활성화:
resource "grafana_data_source" "azure_monitor" {
type = "grafana-azure-monitor-datasource"
name = "Azure Monitor"
json_data_encoded = jsonencode({
azureAuthType = "clientsecret"
cloudName = "azuremonitor"
tenantId = "<TENANT_ID>"
clientId = "<CLIENT_ID>"
subscriptionId = "<SUBSCRIPTION_ID>"
basicLogsEnabled = true
})
secure_json_data_encoded = jsonencode({
clientSecret = "<CLIENT_SECRET>"
})
}
프로비저닝 빠른 참조
| 인증 방법 | azureAuthType 값 | 필수 필드 |
|---|---|---|
| App Registration (client secret) | clientsecret | tenantId, clientId, clientSecret |
| App Registration (certificate) | clientcertificate | tenantId, clientId, certificateFormat, clientCertificate |
| Managed Identity | msi | 없음 (VM identity 사용) |
| Workload Identity | workloadidentity | 없음 (Pod identity 사용) |
| Current User | currentuser | oauthPassThru: true, disableGrafanaCache: true |
모든 방법은 기본 구독을 설정하는 선택적 subscriptionId 필드를 지원해요.