Prometheus 데이터 소스 구성

Prometheus 데이터 소스 구성 (Configure the Prometheus data source)

이 문서는 Prometheus 데이터 소스를 구성하는 방법과 사용 가능한 구성 옵션을 설명해요. Prometheus 데이터 소스는 Grafana에 미리 설치되어 있으므로 수동 설치가 필요 없어요. Grafana에 데이터 소스를 추가하는 일반적인 방법은 "데이터 소스 추가" 문서를 참고하세요.

출처: 문서

본문

데이터 소스 추가

Prometheus 데이터 소스를 추가하려면:

  1. Grafana 메뉴에서 Connections > Data sources로 이동합니다.
  2. Add data source를 클릭하고 Prometheus를 선택합니다.
  3. Grafana가 Prometheus 구성을 설정하는 Settings 탭으로 안내해요.

구성 옵션 (Configuration options)

Settings 탭의 구성 옵션은 UI에 나타나는 순서대로 설명합니다.

  • Name and default: 기본 데이터 소스 설정.
  • Connection: URL과 접근 방식.
  • Authentication: Prometheus 데이터 소스에는 세 가지 인증 옵션이 있어요. 배포 방식에 따라 추가 인증 방법(Azure AD, AWS SigV4)을 사용할 수 있어요.

    경고: Grafana 13에서 핵심 Prometheus 데이터 소스의 Azure AD 및 SigV4 인증은 더 이상 사용되지 않습니다(deprecated). 이 방법을 쓰는 기존 데이터 소스는 시작 시 전용 플러그인으로 자동 마이그레이션돼요. 새로 구성할 때는 Azure Monitor Managed Service for Prometheus나 Amazon Managed Service for Prometheus 플러그인을 사용하세요. 참고: 인증 드롭다운에 Azure AD나 SigV4 옵션이 안 보이면 필요한 기능 플래그가 인스턴스에서 활성화되지 않은 거예요. Grafana Cloud는 지원 요청을 제출하고, 자체 관리 인스턴스는 Grafana 구성 파일을 업데이트하세요.

  • TLS settings: Prometheus 작업 시 추가 보안 계층으로 TLS를 사용할 수 있어요.
  • HTTP headers: 요청이나 응답에 대한 추가 정보와 메타데이터를 전달해요.
  • Advanced HTTP settings: 고급 HTTP 설정.
  • Alerting: 알림 설정.
  • Interval behavior: 간격 동작.
  • Query editor: 쿼리 에디터 설정.
  • Performance: 성능 설정.

    참고: Prometheus 데이터 소스의 팀 기반 라벨 기반 접근 제어(LBAC)는 백엔드가 Grafana Cloud Metrics(Mimir)나 Grafana Enterprise Metrics(GEM)여야 해요. LBAC는 Google Managed Prometheus, 자체 관리 Prometheus, Thanos 같은 외부 Prometheus 호환 엔드포인트에서는 동작하지 않아요. LBAC 적용은 다른 백엔드가 지원하지 않는 Mimir 전용 HTTP 헤더에 의존하기 때문이에요.

  • Other: 기타 설정.
  • Exemplars: exemplar 지원은 Prometheus 데이터 소스에서만 사용할 수 있어요. exemplar는 주어진 시간 간격 내에서 수행된 특정 측정을 나타내는 트레이스예요. + 기호를 클릭해 exemplar를 추가할 수 있고, 여러 exemplar 구성을 추가할 수 있어요.
  • Private data source connect (PDC):

    참고: PDC는 Grafana Cloud 사용자만 사용할 수 있어요. PDC를 사용하면 인바운드 트래픽에 네트워크를 열지 않고 Grafana Cloud 인스턴스와 프라이빗 네트워크의 데이터 소스 사이에 프라이빗하고 보안된 연결을 설정할 수 있어요. PDC는 Prometheus 호환 데이터 소스에 대한 쿼리와 쓰기(writing)를 모두 지원해요. 즉 Grafana가 관리하는 recording rules가 PDC 연결 뒤의 Prometheus나 Mimir 인스턴스에 결과를 쓸 수 있어요. PDC를 SigV4와 함께 사용하면 PDC 에이전트가 sts.<region>.amazonaws.com:443로 인터넷 이그레스를 허용해야 해요. Manage private data source connect networks를 클릭해 PDC 구성 상세를 볼 수 있어요.

저장 및 테스트 (Save and test)

구성을 마친 뒤 하단의 Save & test를 클릭해 데이터 소스 연결을 테스트해요. 확인 메시지가 나타나야 해요:

Successfully queried the Prometheus API.

연결을 제거하려면 Delete를 클릭해도 돼요.

데이터 소스 프로비저닝 (Provision the data source)

데이터 소스를 Grafana 프로비저닝 시스템의 일부로 YAML 파일로 정의하거나, Grafana Terraform 프로바이더로 정의할 수 있어요.

참고: 데이터 소스를 프로비저닝한 뒤에는 UI로 편집할 수 없어요.

YAML로 프로비저닝

Prometheus 데이터 소스 구성 예시:

apiVersion: 1

datasources:
  - name: Prometheus
    type: prometheus
    access: proxy
    url: http://localhost:9090
    jsonData:
      httpMethod: POST
      manageAlerts: true
      allowAsRecordingRulesTarget: true
      prometheusType: Prometheus
      prometheusVersion: 3.3.0
      cacheLevel: 'High'
      disableRecordingRules: false
      seriesEndpoint: false
      timeInterval: 10s
      incrementalQueryOverlapWindow: 10m
      exemplarTraceIdDestinations:
        - datasourceUid: my_jaeger_uid
          name: traceID
        - name: traceID
          url: 'http://localhost:3000/explore?orgId=1&left=%5B%22now-1h%22,%22now%22,%22Jaeger%22,%7B%22query%22:%22$${__value.raw}%22%7D%5D'

Terraform으로 프로비저닝

Grafana Terraform 프로바이더를 사용해 Prometheus 데이터 소스를 구성할 수 있어요. 일반적인 설정으로 데이터 소스를 만드는 예시:

resource "grafana_data_source" "prometheus" {
  name = "Prometheus"
  type = "prometheus"
  url  = "http://localhost:9090"

  json_data_encoded = jsonencode({
    httpMethod                    = "POST"
    manageAlerts                  = true
    prometheusType                = "Prometheus"
    prometheusVersion             = "3.3.0"
    cacheLevel                    = "High"
    disableRecordingRules         = false
    incrementalQuerying           = true
    incrementalQueryOverlapWindow = "10m"
    timeInterval                  = "15s"
    exemplarTraceIdDestinations = [{
      datasourceUid = "my_tempo_uid"
      name          = "traceID"
    }]
  })
}

기본 인증을 사용하는 Prometheus 데이터 소스 예시:

resource "grafana_data_source" "prometheus_auth" {
  name = "Prometheus (authenticated)"
  type = "prometheus"
  url  = "https://prometheus.example.com:9090"

  basic_auth_enabled  = true
  basic_auth_username = "grafana"

  json_data_encoded = jsonencode({
    httpMethod     = "POST"
    prometheusType = "Mimir"
    timeInterval   = "15s"
  })

  secure_json_data_encoded = jsonencode({
    basicAuthPassword = var.prometheus_password
  })
}

Azure 인증 설정 (사용 중단됨, deprecated)

경고: Grafana 13에서 핵심 Prometheus 데이터 소스의 Azure AD 인증은 사용 중단됐어요. 이 방법을 쓰는 데이터 소스는 시작 시 전용 Azure Monitor Managed Service for Prometheus 플러그인으로 자동 마이그레이션돼요.

여전히 핵심 Prometheus 데이터 소스에 Azure AD 인증을 구성해야 한다면(예: 구버전 Grafana), .ini 구성 파일의 [auth] 섹션에 다음 설정을 추가하세요:

[auth]
azure_auth_enabled = true

참고: Azure 인증을 사용한다면 Forward OAuth identity를 활성화하지 마세요. 두 방법 모두 같은 HTTP 권한 부여 헤더를 사용하며, OAuth 토큰이 Azure 자격 증명을 덮어쓰기 때문이에요.

문제 해결

구성 후 문제가 발생하면 "Prometheus 데이터 소스 문제 해결" 문서를 참고하세요.

더 알아보기 (Learn more)