Prometheus를 사용하여 Config Connect 모니터링


Prometheus를 사용하여 Config Connect에서 측정항목을 수집하고 표시할 수 있습니다.

시작하기 전에

이 문서의 단계를 완료하려면 클러스터에 Prometheus를 설치해야 합니다. 그 방법은 다음과 같습니다.

측정항목 스크랩

Prometheus는 HTTP 엔드포인트를 스크랩하여 측정항목을 수집합니다. 이 섹션에서는 Config Connect 스크랩 엔드포인트 및 Prometheus 구성에 대해 설명합니다.

Config Connect 스크랩 엔드포인트

Config Connector의 경우 서비스 엔드포인트는 cnrm-controller-manager-servicecnrm-resource-stats-recorder-service에서 포트 8888에 있습니다. 이러한 서비스에는 prometheus.io/scrape: "true"prometheus.io/port: "8888" 주석이 포함됩니다. 서비스에는 또한 cnrm.cloud.google.com/monitored: "true"cnrm.cloud.google.com/system: "true" 라벨이 포함됩니다. 이러한 주석 및 라벨로부터 Config Connector 구성요소를 스크랩하도록 Prometheus를 구성합니다.

Prometheus 구성

측정항목을 스크랩하기 전에 Kubernetes REST API에서 스크랩 대상을 검색하도록 Kubernetes Service Discovery(SD)에 대해 Prometheus를 구성해야 합니다.

Config Connect에서 측정항목을 스크랩하도록 Prometheus를 구성하는 방법은 Prometheus를 설치한 방법에 따라 다릅니다. 구성 업데이트 방법은 Prometheus 설치 문서를 참조하세요.

예를 들어 Prometheus 연산자를 사용 중이고 이 연산자를 ServiceMonitor로 구성한 경우 다음 구성을 적용하여 Config Connect에서 측정항목을 스크랩할 수 있습니다.

  spec:
    endpoints:
    - interval: 10s
      port: metrics
    namespaceSelector:
      matchNames:
      - cnrm-system
    selector:
      matchLabels:
        cnrm.cloud.google.com/monitored: "true"
        cnrm.cloud.google.com/system: "true"

ServiceMonitor 설정에 대한 자세한 내용은 Prometheus 연산자 문서에서 시작하기를 참조하세요.

쿼리 예

Prometheus는 PromQL이라는 쿼리 언어를 사용합니다. 이 섹션에는 Config Connector의 측정항목에 대한 PromQL 쿼리 예시가 포함되어 있습니다. 모든 유효한 PromQL 쿼리에서 알림을 생성하도록 Prometheus를 구성할 수 있습니다.

리소스 종류 및 상태별로 조정 요청 쿼리

리소스 종류 및 상태에 따라 실패한 조정 요청 수를 확인할 수 있습니다.

예를 들어 PubSubTopic 리소스의 총 오류 수를 확인하려면 다음 쿼리를 사용하세요.

configconnector_reconcile_requests_total{group_version_kind="PubSubTopic.pubsub.cnrm.cloud.google.com", status="ERROR"}

종류 및 네임스페이스별로 리소스의 집계 상태 확인

네임스페이스에 있는 리소스 수를 확인할 수 있습니다.

예를 들어, default 네임스페이스에서 PubSubTopic 리소스의 총 수를 확인하려면 다음 쿼리를 사용하세요.

configconnector_applied_resources_total{group_version_kind="PubSubTopic.pubsub.cnrm.cloud.google.com", Namespace="default"}

리소스 종류별로 조정 워커의 사용률 쿼리

(configconnector_reconcile_occupied_workers_total / configconnector_reconcile_workers_total)

사용 가능한 측정항목

Config Connect는 다음 측정항목을 수집하여 사용 가능하게 합니다.

이름 유형 라벨 설명
configconnector_reconcile_requests_total 카운터 네임스페이스
group_version_kind
상태
총 조정 요청 수
configconnector_reconcile_request_duration_seconds 히스토그램 네임스페이스
group_version_kind
상태
조정 요청을 완료하기 위한 시간 분포
configconnector_applied_resources_total 게이지 네임스페이스
group_version_kind
상태
관리 중인 총 리소스 수
configconnector_build_info 게이지 버전 Config Connect의 현재 버전
configconnector_reconcile_workers_total 게이지 group_version_kind 리소스 종류별로 집계된 총 조정 워커의 총 수
configconnector_reconcile_occupied_workers_total 게이지 group_version_kind 리소스 종류별로 집계된 점유 조정 워커의 총 수

리소스 이름 라벨 사용

기본적으로 측정항목은 리소스 종류(예: PubSubTopic)에 따라 집계됩니다. 개별 리소스별로 측정항목을 집계할 수 있습니다.

리소스 이름별로 집계를 사용하려면 다음 단계를 수행하세요.

  1. cnrm-controller-manager StatefulSet 객체를 편집합니다.

    kubectl edit statefulset cnrm-controller-manager -n cnrm-system

    네임스페이스 모드를 사용하는 경우 NAMESPACE_NAME을 사용자의 네임 스페이스로 바꿉니다.

    kubectl edit statefulset cnrm-controller-manager -n NAMESPACE_NAME
  2. spec.args 배열을 찾고 --resource-name-label=true을 추가합니다.

    apiVersion: apps/v1
    kind: StatefulSet
      name: cnrm-controller-manager
    spec:
      template:
        spec:
          containers:
          - name: manager
      args:
            - --resource-name-label=true
    

다음 단계

쿼리 작성에 대한 자세한 정보는 Prometheus 쿼리 언어 문서예시를 참조하세요.