상용화 이전: 2026-02-26

7 Prometheus에서 Besu 측정항목 모니터링

Prometheus 및 kube-prometheus-stack을 사용하여 Kubernetes 클러스터에서 실행되는 Besu 노드에서 측정항목을 검색할 수 있습니다.

모니터링을 설치하려면 Helm, kube-prometheus-stack 및 Consensys/quorum-kubernetes 저장소에서 유지 관리되는 미리 정의된 값 파일(monitoring.yml)을 사용합니다. 이 시나리오에서 Prometheus는 Istio 서비스 메시 내에서 작동하며 상호 TLS를 통해 메트릭을 안전하게 스크랩합니다. kube-prometheus-stack 패키지는 다음 소프트웨어를 설치합니다.
  • Prometheus
  • 프로메테우스 연산자
  • Grafana
  • 경고 관리자
  • 표준 Kubernetes 익스포트 프로그램

kube-prometheus-stack 아키텍처에서 Prometheus는 ServiceMonitor이라는 Kubernetes 사용자 정의 리소스를 사용하여 스크랩 대상을 검색합니다. 이 리소스는 스크랩할 서비스, 측정항목을 노출하는 포트 및 경로, TLS 및 상호 TLS에 대한 구성을 정의합니다. ServiceMonitor kube-state-metrics 및 node-exporter와 같은 구성요소에 대한 리소스는 Helm을 사용하여 kube-prometheus-stack을 설치할 때 자동으로 생성됩니다. 그러나 Hyperledger Besu 측정지표용 Oracle Blockchain Platform Enterprise Edition을 스크랩하려면 고유한 ServiceMonitor 리소스를 생성하고 관리해야 합니다.

다음 필수 조건을 설치합니다.
  • Helm v3.x입니다. 다음 명령을 실행하여 Helm 버전을 확인할 수 있습니다.
    helm version
  • kubectl
또한 Kubernetes 클러스터에 대한 명령줄 액세스 권한이 있어야 합니다. 자세한 내용은 Oracle Kubernetes Engine에 연결을 참조하십시오.
  1. Besu와 호환되는 monitoring.yml 파일을 사용하여 kube-prometheus-stack을 설치합니다.
    1. 다음 명령을 입력하여 파일을 다운로드합니다. monitoring.yml 파일은 Consensys/quorum-kubernetes 저장소에서 유지 관리됩니다.
      curl -o monitoring.yml \ 
      https://raw.githubusercontent.com/Consensys/quorum-kubernetes/master/helm/values/monitoring.yml 
    2. 필요한 경우 배포 전에 monitoring.yml에서 Grafana 관리자 비밀번호를 업데이트하고 경보 수신기(예: 전자메일 또는 Slack)를 구성합니다.
    3. 아직 없는 경우 Prometheus 커뮤니티 Helm 저장소를 추가합니다.
      helm repo add prometheus-community https://prometheus-community.github.io/helm-charts 
      helm repo update 
    4. 모니터링 전용 네임스페이스에 모니터링 스택을 설치합니다. 다음 명령에서 이름 공간을 모니터링이라고 합니다.
      helm install monitoring prometheus-community/kube-prometheus-stack \ 
        --version 34.10.0 \ 
        --namespace monitoring \ 
        --create-namespace \ 
        --values monitoring.yml 
    5. 다음 명령을 실행하여 배치 상태를 확인합니다.
      kubectl get pods -n monitoring -l release=monitoring
    설치 프로세스는 모니터링 스택을 monitoring 네임스페이스에 배포하고, Besu 호환성을 위해 monitoring.yml 파일의 재정의를 적용하고, 스택에 필요한 표준 쿠버넷 ServiceMonitor 리소스를 만듭니다.
  2. monitoring.yml 파일에 Istio 주석을 추가하여 Prometheus에 대한 Istio 사이드카 주입을 사용으로 설정합니다. Prometheus는 상호 TLS를 통해 Besu 엔드포인트를 스크레이핑하기 위해 Istio 메쉬에 가입해야 합니다. 편집할 monitoring.yml 파일을 열고 다음 섹션을 찾습니다.
    prometheus: 
      prometheusSpec: 
        podMetadata:
    다음 Istio 주석을 추가합니다.
    prometheus: 
      prometheusSpec: 
        podMetadata: 
          annotations: 
            sidecar.istio.io/inject: "true" 
            sidecar.istio.io/userVolumeMount: | 
              [{"name": "istio-certs", "mountPath": "/etc/istio-certs", "readOnly": true}] 
            proxy.istio.io/config: | 
              proxyMetadata: 
                OUTPUT_CERTS: /etc/istio-certs 
              proxyMetadata.INBOUND_CAPTURE_PORTS: "" 
    이러한 주석은 Istio 메시에 Prometheus를 추가하고, 작업 로드 mTLS 인증서를 공유 볼륨에 기록하도록 Istio를 구성하며, Envoy가 Prometheus 인바운드 트래픽을 가로채지 못하도록 하고, Istio가 생성한 인증서를 Prometheus 컨테이너에서 사용할 수 있도록 합니다.
  3. 볼륨 및 볼륨 마운트 정보를 monitoring.yml 파일에 추가하여 Istio 인증서를 Prometheus에 마운트합니다. monitoring.yml 파일에서 다음 텍스트를 찾습니다.
    처음에 비어 있는 volumes 섹션을 찾습니다.
        volumes: []
    다음 텍스트와 같이 volumes 섹션을 업데이트합니다.
        volumes: 
          - name: istio-certs 
            emptyDir: 
              medium: Memory 
     
    처음에 비어 있는 volumeMounts 섹션을 찾습니다.
        volumeMounts: []
    다음 텍스트와 같이 volumeMounts 섹션을 업데이트합니다.
        volumeMounts: 
          - name: istio-certs 
            mountPath: /etc/prom-certs 
            readOnly: true
    Istio에서 생성된 인증서는 이제 Prometheus(/etc/prom-certs/.)에서 사용할 수 있습니다.
  4. 업데이트된 구성을 적용합니다.
    1. 기존 Helm 릴리스를 수정된 값 파일로 업그레이드합니다.
      helm upgrade monitoring prometheus-community/kube-prometheus-stack \ 
        --namespace monitoring \ 
        --values monitoring.yml 
    2. Prometheus Pod가 다시 시작되었고 Istio 사이드카로 실행 중인지 확인합니다.
      kubectl get pods -n monitoring | grep prometheus 
  5. 다음 예제를 사용하여 Besu 측정항목에 대한 ServiceMonitor 리소스를 만듭니다.
    apiVersion: monitoring.coreos.com/v1 
    kind: ServiceMonitor 
    metadata: 
      name: obp-besu-rpc-metrics 
      namespace: <besu-namespace> 
      labels: 
        release: monitoring   # Must match Prometheus serviceMonitorSelector 
    spec: 
      selector: 
        matchLabels: 
          app: besu 
          besu-role: rpc 
      namespaceSelector: 
        matchNames: 
          - <besu-namespace> 
      endpoints: 
        - port: metrics 
          path: /metrics 
          interval: 30s 
          scheme: https 
          tlsConfig: 
            caFile: /etc/prom-certs/root-cert.pem 
            certFile: /etc/prom-certs/cert-chain.pem 
            keyFile: /etc/prom-certs/key.pem 
            insecureSkipVerify: true 
    인증서 경로는 마운트된 위치(etc/prom-certs)와 일치해야 합니다. release 레이블은 Prometheus의 serviceMonitorSelector 값과 일치해야 합니다. 이전 예제에서는 RPC 노드(besu-role: rpc)에서 측정항목을 스크랩합니다. 부트 노드, 검증기 노드 또는 아카이브 노드에서 측정항목을 스크랩하려면 별도의 ServiceMonitor 리소스를 만들고 그에 따라 besu-role 레이블(bootnode, validator 또는 archive)을 편집합니다.
  6. Prometheus에서 측정 단위가 수집되고 있는지 확인합니다.
    1. 다음 명령을 실행하여 Prometheus 서비스의 포트를 전달합니다.
      kubectl port-forward -n <namespace> prometheus-monitoring-kube-prometheus-prometheus-
    2. http://localhost:9090를 열고 상태, 대상 순으로 선택합니다. Besu 대상이 UP 상태인지 확인합니다.
    3. 다음 예제와 같은 샘플 query를 실행합니다.
      besu_blockchain_chain_head_transaction_count 
  7. Grafana에 액세스하여 측정지표가 수집되고 있는지 확인합니다. 다음 명령을 실행하여 Grafana 서비스의 포트를 전달합니다.
    kubectl port-forward svc/monitoring-grafana -n <namespace> 3000:80 
    • URL: http://localhost:3000
    • 사용자 이름: admin
    • 다음 명령을 실행하여 암호를 검색합니다.
      kubectl get secret -n <namespace> monitoring-grafana \ 
      -o jsonpath="{.data.admin-password}" | base64 --decode ; echo