시작: Azure IoT 작업 미리 보기에서 스크립트로 가시성 구성

Important

Azure IoT 작업 미리 보기 - Azure Arc에서 지원되는 Azure IoT 작업은 현재 preview로 제공됩니다. 프로덕션 환경에서는 이 미리 보기 소프트웨어를 사용하면 안 됩니다.

일반적으로 릴리스되는 릴리스가 제공되면 새로운 Azure IoT 작업 설치를 배포해야 합니다. 미리 보기 설치는 업그레이드할 수 없습니다.

베타, 미리 보기로 제공되거나 아직 일반 공급으로 릴리스되지 않은 Azure 기능에 적용되는 약관은 Microsoft Azure 미리 보기에 대한 추가 사용 약관을 참조하세요.

가시성은 Azure IoT 작업 구성의 모든 계층에 대한 표시 여부를 제공합니다. 문제의 실제 동작에 대한 인사이트를 제공하여 사이트 안정성 엔지니어링의 효율성을 높입니다. Azure IoT 작업은 Azure에서 호스트되는 사용자 지정 큐레이팅된 Grafana 대시보드를 통해 가시성성을 제공합니다. 이러한 대시보드는 Azure Monitor Prometheus용 관리 서비스 및 Container Insights를 통해 제공됩니다. 이 문서에서는 가시성에 필요한 서비스를 구성하는 방법을 보여 줍니다.

필수 조건

  • Arc 지원 Kubernetes 클러스터.
  • 개발 머신에 설치된 Helm입니다. 지침은 Helm 설치를 참조 하세요.
  • 개발 머신에 설치된 Kubectl입니다. 자세한 내용은 Kubernetes 도구 설치를 참조 하세요.
  • 개발 컴퓨터에 설치된 Azure CLI입니다. 자세한 내용은 Azure CLI 설치 방법을 참조하세요.

구독 구성

다음 코드를 실행하여 클러스터가 있는 구독에 공급자를 등록하세요.

참고 항목

이 단계는 구독당 한 번만 실행하면 됩니다. 리소스 공급자를 등록하려면 구독 기여자 및 소유자 역할에 포함된 /register/action 작업을 수행할 수 있는 권한이 필요합니다. 자세한 내용은 Azure 리소스 공급자 및 형식을 참조하세요.

az account set -s <subscription-id>
az provider register -n "Microsoft.Insights"
az provider register -n "Microsoft.AlertsManagement"

가시성 구성 요소 설치

이 섹션의 단계에서는 OTel(OpenTelemetry) 수집기를 배포한 다음 공유 모니터링 리소스를 설치하고 이러한 리소스에 관찰성 신호를 내보내도록 Arc 지원 클러스터를 구성합니다. 공유 모니터링 리소스에는 Azure Managed Grafana, Azure Monitor Workspace, Azure Managed Prometheus, Azure Log Analytics 및 Container Insights가 포함됩니다.

OpenTelemetry 수집기 배포

  1. Azure IoT Operations 리포지토리를 복제하거나 로컬 머신 (azure-iot-operations.git)에 다운로드합니다.

    참고 항목

    해당 리포지토리에는 Azure IoT 작업의 배포 정의와 이 문서에서 사용된 샘플 대시보드가 ​​포함된 샘플이 포함되어 있습니다.

  2. 리포지토리의 로컬 복사본에서 다음 경로를 찾습니다.

    azure-iot-operations\tools\setup-3p-obs-infra

  3. 호출 otel-collector-values.yaml 된 파일을 만들고 다음 코드를 붙여넣어 OpenTelemetry 수집기를 정의합니다.

    mode: deployment
    fullnameOverride: aio-otel-collector
    image:
      repository: otel/opentelemetry-collector
      tag: 0.107.0
    config:
      processors:
        memory_limiter:
          limit_percentage: 80
          spike_limit_percentage: 10
          check_interval: '60s'
      receivers:
        jaeger: null
        prometheus: null
        zipkin: null
        otlp:
          protocols:
            grpc:
              endpoint: ':4317'
            http:
              endpoint: ':4318'
      exporters:
        prometheus:
          endpoint: ':8889'
          resource_to_telemetry_conversion:
            enabled: true
      service:
        extensions:
          - health_check
        pipelines:
          metrics:
            receivers:
              - otlp
            exporters:
              - prometheus
          logs: null
          traces: null
        telemetry: null
      extensions:
        memory_ballast:
          size_mib: 0
    resources:
      limits:
        cpu: '100m'
        memory: '512Mi'
    ports:
      metrics:
        enabled: true
        containerPort: 8889
        servicePort: 8889
        protocol: 'TCP'
      jaeger-compact:
        enabled: false
      jaeger-grpc:
        enabled: false
      jaeger-thrift:
        enabled: false
      zipkin:
        enabled: false
    
  4. otel-collector-values.yaml 파일에서 클러스터에 Azure IoT Operations를 az iot ops init 배포할 때 명령에서 사용하는 다음 값을 기록해 둡니다.

    • fullnameOverride
    • grpc.endpoint
    • check_interval
  5. 파일을 저장 후 닫습니다.

  6. 다음 명령을 실행하여 수집기를 배포합니다.

    kubectl get namespace azure-iot-operations || kubectl create namespace azure-iot-operations
    helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
    
    helm repo update
    helm upgrade --install aio-observability open-telemetry/opentelemetry-collector -f otel-collector-values.yaml --namespace azure-iot-operations
    

관찰성 구성 요소 배포

  • 다음 명령 중 하나를 실행하여 관찰성 구성 요소를 배포합니다. 모니터링하려는 Arc 지원 클러스터의 구독 ID 및 리소스 그룹을 사용합니다.

    참고 항목

    설정할 수 있는 다른 선택적 매개 변수를 알아보려면 bicep 파일을 참조하세요. 선택적 매개 변수는 클러스터 리소스에 대한 대체 위치와 같은 사항을 지정할 수 있습니다.

    다음 명령은 사용자에게 새로 만든 Grafana 인스턴스에 대한 관리자 액세스 권한을 부여합니다.

    az deployment group create \
         --subscription <subscription-id> \
         --resource-group <cluster-resource-group> \
         --template-file observability-full.bicep \
         --parameters grafanaAdminId=$(az ad user show --id $(az account show --query user.name --output tsv) --query=id --output tsv) \
                      clusterName=<cluster-name> \
                      sharedResourceGroup=<shared-resource-group> \
                      sharedResourceLocation=<shared-resource-location> \
         --query=properties.outputs
    

    해당 액세스가 원하는 액세스가 아닌 경우 권한을 구성하지 않는 다음 명령을 실행합니다. 그런 다음, 누구나 Grafana 인스턴스에 액세스하기 전에 역할 할당을 사용하여 수동으로 권한을 설정합니다. 원하는 액세스 수준에 따라 Grafana 역할(Grafana Admin, Grafana Editor, Grafana Viewer) 중 하나를 할당합니다.

    az deployment group create \
         --subscription <subscription-id> \
         --resource-group <cluster-resource-group> \
         --template-file observability-full.bicep \
         --parameters clusterName=<cluster-name> \
                      sharedResourceGroup=<shared-resource-group> \
                      sharedResourceLocation=<shared-resource-location> \
          --query=properties.outputs
    

    배포에 성공하면 명령 출력의 끝에 몇 가지 정보가 인쇄됩니다. 이 정보에는 만들어진 Log Analytics 및 Azure Monitor 리소스에 대한 Grafana URL과 리소스 ID가 포함됩니다. Grafana URL을 사용하면 Grafana에 대시보드 배포에서 구성한 Grafana 인스턴스로 이동할 수 있습니다. 두 개의 리소스 ID를 사용하면 기존 가시성 인프라에 Arc 지원 클러스터 추가의 단계에 따라 다른 Arc 지원 클러스터를 구성할 수 있습니다.

Prometheus 메트릭 컬렉션 구성

  1. 다음 구성을 복사하여 새 ama-metrics-prometheus-config.yaml파일에 붙여넣고 파일을 저장합니다.

    apiVersion: v1
    data:
      prometheus-config: |2-
        scrape_configs:
          - job_name: e4k
            scrape_interval: 1m
            static_configs:
              - targets:
                - aio-internal-diagnostics-service.azure-iot-operations.svc.cluster.local:9600
              - job_name: nats
                scrape_interval: 1m
                static_configs:
                - targets:
                  - aio-dp-msg-store-0.aio-dp-msg-store-headless.azure-iot-operations.svc.cluster.local:7777
              - job_name: otel
                scrape_interval: 1m
                static_configs:
                - targets:
                  - aio-otel-collector.azure-iot-operations.svc.cluster.local:8889
              - job_name: aio-annotated-pod-metrics
                kubernetes_sd_configs:
                - role: pod
                  relabel_configs:
                  - action: drop
                    regex: true
                    source_labels:
                    - __meta_kubernetes_pod_container_init
                  - action: keep
                    regex: true
                    source_labels:
                    - __meta_kubernetes_pod_annotation_prometheus_io_scrape
                  - action: replace
                    regex: ([^:]+)(?::\\d+)?;(\\d+)
                    replacement: $1:$2
                    source_labels:
                    - __address__
                    - __meta_kubernetes_pod_annotation_prometheus_io_port
                    target_label: __address__
                  - action: replace
                    source_labels:
                    - __meta_kubernetes_namespace
                    target_label: kubernetes_namespace
                  - action: keep
                    regex: 'azure-iot-operations'
                    source_labels:
                    - kubernetes_namespace
                  scrape_interval: 1m
    kind: ConfigMap
    metadata:
      name: ama-metrics-prometheus-config
      namespace: kube-system
    
  2. 다음 명령을 실행하여 구성 파일을 적용합니다.

    kubectl apply -f ama-metrics-prometheus-config.yaml
    

Grafana에 대시보드 배포

Azure IoT 작업은 Azure IoT 작업 배포의 상태 및 성능을 이해하는 데 필요한 많은 시각화를 제공하도록 설계된 대시보드 컬렉션을 제공합니다.

다음 단계를 완료하여 Azure IoT 작업 큐레이팅된 Grafana 대시보드를 설치합니다.

  1. Grafana 콘솔에 로그인한 다음 Grafana 애플리케이션의 오른쪽 상단 영역에서 + 아이콘을 선택합니다.

  2. 대시보드 가져오기를 선택한 다음 프롬프트에 따라 리포지토리의 로컬 복제된 복사본에서 samples\grafana-dashboards 경로를 찾아 JSON 대시보드 파일을 선택합니다.

  3. 애플리케이션이 프롬프트를 표시하면 관리되는 Prometheus 데이터 원본을 선택합니다.

  4. 가져오기를 선택합니다.