テレメトリーデータの転送


Red Hat build of OpenTelemetry 3.8

可観測性バックエンドおよびクラウドプラットフォームへのトレース、ログ、およびメトリクスのエクスポート

Red Hat OpenShift Documentation Team

概要

このドキュメントでは、Telemetry データを OpenTelemetry Collector からさまざまな宛先に転送する方法について説明します。トレースを TempoStack、LokiStack に、Telemetry データをサードパーティーシステムにエクスポートする方法を学習します。AWS サービス(CloudWatch Logs、EMF、X-Ray)および Google Cloud Operations Suite (Cloud Monitoring、Cloud Logging、Cloud Trace)とのクラウドプラットフォーム統合の設定手順が含まれています。サービスアカウントの設定、RBAC 設定、OTLP プロトコルの使用、およびカスタム Collector デプロイメントについて説明します。

第1章 テレメトリーデータの転送

テレメトリーデータは、OpenTelemetry Collector を使用して転送できます。

1.1. トレースを TempoStack インスタンスに転送する

TempoStack インスタンスへのトレースの転送を設定するには、OpenTelemetry Collector をデプロイして設定します。指定されたプロセッサー、レシーバー、エクスポーターを使用して、OpenTelemetry Collector をデプロイメントモードでデプロイできます。その他のモードについては、関連情報 に記載されたリンクを使用して、OpenTelemetry Collector ドキュメントを参照してください。

前提条件

  • Red Hat build of OpenTelemetry Operator がインストールされている。
  • Tempo Operator がインストールされている。
  • TempoStack インスタンスがクラスターにデプロイされている。

手順

  1. OpenTelemetry Collector のサービスアカウントを作成します。

    ServiceAccount の例

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: otel-collector-deployment
    Copy to Clipboard Toggle word wrap

  2. サービスアカウントのクラスターロールを作成します。

    ClusterRole の例

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: otel-collector
    rules:
    - apiGroups: [""]
      resources: ["pods", "namespaces",]
      verbs: ["get", "watch", "list"] 
    1
    
    - apiGroups: ["apps"]
      resources: ["replicasets"]
      verbs: ["get", "watch", "list"] 
    2
    
    - apiGroups: ["config.openshift.io"]
      resources: ["infrastructures", "infrastructures/status"]
      verbs: ["get", "watch", "list"] 
    3
    Copy to Clipboard Toggle word wrap

    1
    この例では、pods および namespaces リソースに対するこれらの権限を必要とする Kubernetes Attributes Processor を使用します。
    2
    また、Kubernetes Attributes Processor を使用するため、replicasets リソースに対するこれらの権限も必要です。
    3
    この例では、infrastructures および status リソースに対するこれらの権限を必要とする Resource Detection Processor も使用します。
  3. クラスターロールをサービスアカウントにバインドします。

    ClusterRoleBinding の例

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: otel-collector
    subjects:
    - kind: ServiceAccount
      name: otel-collector-deployment
      namespace: otel-collector-example
    roleRef:
      kind: ClusterRole
      name: otel-collector
      apiGroup: rbac.authorization.k8s.io
    Copy to Clipboard Toggle word wrap

  4. YAML ファイルを作成して、OpenTelemetryCollector カスタムリソース (CR) を定義します。

    OpenTelemetryCollector の例

    apiVersion: opentelemetry.io/v1beta1
    kind: OpenTelemetryCollector
    metadata:
      name: otel
    spec:
      mode: deployment
      serviceAccount: otel-collector-deployment
      config:
        receivers:
          jaeger:
            protocols:
              grpc: {}
              thrift_binary: {}
              thrift_compact: {}
              thrift_http: {}
          opencensus: {}
          otlp:
            protocols:
              grpc: {}
              http: {}
          zipkin: {}
        processors:
          batch: {}
          k8sattributes: {}
          memory_limiter:
            check_interval: 1s
            limit_percentage: 50
            spike_limit_percentage: 30
          resourcedetection:
            detectors: [openshift]
        exporters:
          otlp:
            endpoint: "tempo-simplest-distributor:4317" 
    1
    
            tls:
              insecure: true
        service:
          pipelines:
            traces:
              receivers: [jaeger, opencensus, otlp, zipkin] 
    2
    
              processors: [memory_limiter, k8sattributes, resourcedetection, batch]
              exporters: [otlp]
    Copy to Clipboard Toggle word wrap

    1
    Collector エクスポーターは、OTLP をエクスポートするように設定され、作成済みの Tempo ディストリビューターエンドポイント (この例では "tempo-simplest-distributor:4317") を指します。
    2
    Collector は、Jaeger トレース、OpenCensus プロトコル経由の OpenCensus トレース、Zipkin プロトコル経由の Zipkin トレース、および gRPC プロトコル経由の OTLP トレースのレシーバーを使用して設定されます。
ヒント

telemetrygen をテストとしてデプロイできます。

apiVersion: batch/v1
kind: Job
metadata:
  name: telemetrygen
spec:
  template:
    spec:
      containers:
        - name: telemetrygen
          image: ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:latest
          args:
            - traces
            - --otlp-endpoint=otel-collector:4317
            - --otlp-insecure
            - --duration=30s
            - --workers=1
      restartPolicy: Never
  backoffLimit: 4
Copy to Clipboard Toggle word wrap

1.2. LokiStack インスタンスへのログの転送

openshift-logging テナントモードを使用して OpenTelemetry Collector をデプロイすると、ログを LokiStack インスタンスに転送できます。

前提条件

  • Red Hat build of OpenTelemetry Operator がインストールされている。
  • Loki Operator がインストールされている。
  • サポートされている LokiStack インスタンスがクラスターにデプロイされている。サポートされている LokiStack 設定の詳細は、Logging を参照してください。

手順

  1. OpenTelemetry Collector のサービスアカウントを作成します。

    ServiceAccount オブジェクトの例

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: otel-collector-deployment
      namespace: openshift-logging
    Copy to Clipboard Toggle word wrap

  2. Collector のサービスアカウントに、ログを LokiStack アプリケーションテナントにプッシュする権限を付与するクラスターロールを作成します。

    ClusterRole オブジェクトの例

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: otel-collector-logs-writer
    rules:
     - apiGroups: ["loki.grafana.com"]
       resourceNames: ["logs"]
       resources: ["application"]
       verbs: ["create"]
     - apiGroups: [""]
       resources: ["pods", "namespaces", "nodes"]
       verbs: ["get", "watch", "list"]
     - apiGroups: ["apps"]
       resources: ["replicasets"]
       verbs: ["get", "list", "watch"]
     - apiGroups: ["extensions"]
       resources: ["replicasets"]
       verbs: ["get", "list", "watch"]
    Copy to Clipboard Toggle word wrap

  3. クラスターロールをサービスアカウントにバインドします。

    ClusterRoleBinding オブジェクトの例

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: otel-collector-logs-writer
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: otel-collector-logs-writer
    subjects:
      - kind: ServiceAccount
        name: otel-collector-deployment
        namespace: openshift-logging
    Copy to Clipboard Toggle word wrap

  4. OpenTelemetryCollector カスタムリソース (CR) オブジェクトを作成します。

    OpenTelemetryCollector CR オブジェクトの例

    apiVersion: opentelemetry.io/v1beta1
    kind: OpenTelemetryCollector
    metadata:
      name: otel
      namespace: openshift-logging
    spec:
      serviceAccount: otel-collector-deployment
      config:
        extensions:
          bearertokenauth:
            filename: "/var/run/secrets/kubernetes.io/serviceaccount/token"
        receivers:
          otlp:
            protocols:
              grpc: {}
              http: {}
        processors:
          k8sattributes: {}
          resource:
            attributes: 
    1
    
              - key:  kubernetes.namespace_name
                from_attribute: k8s.namespace.name
                action: upsert
              - key:  kubernetes.pod_name
                from_attribute: k8s.pod.name
                action: upsert
              - key: kubernetes.container_name
                from_attribute: k8s.container.name
                action: upsert
              - key: log_type
                value: application
                action: upsert
          transform:
            log_statements:
              - context: log
                statements:
                  - set(attributes["level"], ConvertCase(severity_text, "lower"))
        exporters:
          otlphttp:
            endpoint: https://logging-loki-gateway-http.openshift-logging.svc.cluster.local:8080/api/logs/v1/application/otlp
            encoding: json
            tls:
              ca_file: "/var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt"
            auth:
              authenticator: bearertokenauth
          debug:
            verbosity: detailed
        service:
          extensions: [bearertokenauth] 
    2
    
          pipelines:
            logs:
              receivers: [otlp]
              processors: [k8sattributes, transform, resource]
              exporters: [otlphttp] 
    3
    
            logs/test:
              receivers: [otlp]
              processors: []
              exporters: [debug]
    Copy to Clipboard Toggle word wrap

    1
    Web コンソールで使用するリソース属性 kubernetes.namespace_namekubernetes.pod_namekubernetes.container_name、および log_type を指定します。
    2
    OTLP HTTP Exporter に必要な BearerTokenAuth Extension を有効にします。
    3
    OTLP HTTP Exporter が Collector からログをエクスポートできるようにします。
ヒント

telemetrygen をテストとしてデプロイできます。

apiVersion: batch/v1
kind: Job
metadata:
  name: telemetrygen
spec:
  template:
    spec:
      containers:
        - name: telemetrygen
          image: ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:v0.106.1
          args:
            - logs
            - --otlp-endpoint=otel-collector.openshift-logging.svc.cluster.local:4317
            - --otlp-insecure
            - --duration=180s
            - --workers=1
            - --logs=10
            - --otlp-attributes=k8s.container.name="telemetrygen"
      restartPolicy: Never
  backoffLimit: 4
Copy to Clipboard Toggle word wrap

1.3. テレメトリーデータをサードパーティーシステムに転送する

OpenTelemetry Collector は、gRPC または HTTP トランスポート経由で実装された OpenTelemetry Protocol (OTLP) を介し、OTLP エクスポーターを使用してテレメトリーデータをエクスポートします。Telemetry データをサードパーティーシステムに転送する必要があり、Red Hat ビルドの OpenTelemetry で OTLP またはその他のサポートされているプロトコルをサポートしていない場合は、サポートされていないカスタム OpenTelemetry Collector をデプロイして、OTLP 経由で Telemetry データを受信し、カスタムエクスポーターを使用してサードパーティーシステムにエクスポートできます。

警告

Red Hat はカスタムデプロイメントをサポートしていません。

前提条件

  • OTLP 経由でテレメトリーデータをサードパーティーシステムにエクスポートできる、サポート対象外の独自のカスタムエクスポーターを開発している。

手順

  • OperatorHub 経由または手動でカスタム Collector をデプロイします。

    • サードパーティーのシステムでサポートされている場合は、OperatorHub を使用してカスタム Collector をデプロイします。
    • config map、デプロイメント、およびサービスを使用して、カスタム Collector を手動でデプロイします。

      カスタム Collector のデプロイメントの例

      apiVersion: v1
      kind: ConfigMap
      metadata:
        name: custom-otel-collector-config
      data:
        otel-collector-config.yaml: |
          receivers:
            otlp:
              protocols:
                grpc:
          exporters:
            debug: {}
            prometheus:
          service:
            pipelines:
              traces:
                receivers: [otlp]
                exporters: [debug] 
      1
      
      ---
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: custom-otel-collector-deployment
      spec:
        replicas: 1
        selector:
          matchLabels:
            component: otel-collector
        template:
          metadata:
            labels:
              component: otel-collector
          spec:
            containers:
            - name: opentelemetry-collector
              image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:latest 
      2
      
              command:
              - "/otelcol-contrib"
              - "--config=/conf/otel-collector-config.yaml"
              ports:
              - name: otlp
                containerPort: 4317
                protocol: TCP
              volumeMounts:
              - name: otel-collector-config-vol
                mountPath: /conf
                readOnly: true
            volumes:
            - name: otel-collector-config-vol
              configMap:
                name: custom-otel-collector-config
      ---
      apiVersion: v1
      kind: Service
      metadata:
        name: custom-otel-collector-service 
      3
      
        labels:
          component: otel-collector
      spec:
        type: ClusterIP
        ports:
        - name: otlp-grpc
          port: 4317
          targetPort: 4317
        selector:
          component: otel-collector
      Copy to Clipboard Toggle word wrap

      1
      debug は、サードパーティーシステムに必要なエクスポーターに置き換えます。
      2
      イメージは、サードパーティーシステムに必要なエクスポーターを備えた OpenTelemetry Collector の必要なバージョンに置き換えます。
      3
      サービス名は、OTLP エクスポーターを設定するために Red Hat build of OpenTelemetry Collector CR で使用されます。

1.4. テレメトリーデータの AWS への転送

テレメトリーデータを AWS に転送するには、次のエクスポーターで OpenTelemetry Collector を使用します。ログ用の AWS CloudWatch Logs Exporter、メトリクスの場合は AWS EMF Exporter、トレースには AWS X-Ray Exporter を使用します。

1.5. テレメトリーデータの Google Cloud への転送

テレメトリーデータを Google Cloud Operations Suite に転送するには、Google Cloud Exporter で OpenTelemetry Collector を使用します。エクスポーターはメトリクスを Google Cloud Monitoring に送信し、Google Cloud Logging にログを記録し、Google Cloud Trace にトレースします。

法律上の通知

Copyright © 2025 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2026 Red Hat
トップに戻る