トレース、ログ、およびメトリクスを Collector に送信する


Red Hat build of OpenTelemetry 3.8

サイドカーインジェクションを使用して Telemetry データを送信するようにアプリケーションを設定する

Red Hat OpenShift Documentation Team

概要

このドキュメントでは、アプリケーションから OpenTelemetry Collector または TempoStack インスタンスにトレース、ログ、およびメトリクスを送信する方法について説明します。2 つのデプロイメントアプローチについて説明します。これは自動設定にサイドカー挿入を使用し、サイドカーのない手動設定です。サービスアカウントの設定、RBAC パーミッションの設定、複数の異なるモードでの Collector のデプロイ、および Telemetry データエクスポートの環境変数の設定手順が含まれます。

第1章 OpenTelemetry Collector へのトレース、ログ、メトリクスの送信

Red Hat ビルドの OpenTelemetry を設定して使用し、トレース、ログ、メトリクスを OpenTelemetry Collector または TempoStack インスタンスに送信できます。

OpenTelemetry Collector へのトレースとメトリクスの送信は、サイドカー注入の有無にかかわらず可能です。

1.1. サイドカー注入を使用してトレースとメトリクスを OpenTelemetry Collector に送信する

サイドカー注入を使用して、OpenTelemetry Collector インスタンスへのテレメトリーデータの送信をセットアップできます。

Red Hat build of OpenTelemetry Operator では、デプロイメントワークロードへのサイドカー注入と、OpenTelemetry Collector にテレメトリーデータを送信するための計装の自動設定が可能です。

前提条件

  • Red Hat OpenShift distributed tracing platform (Tempo) がインストールされ、TempoStack インスタンスがデプロイされている。
  • Web コンソールまたは OpenShift CLI (oc) を使用してクラスターにアクセスできる。

    • cluster-admin ロールを持つクラスター管理者として Web コンソールにログインしている。
    • cluster-admin ロールを持つクラスター管理者によるアクティブな OpenShift CLI (oc) セッション。
    • Red Hat OpenShift Dedicated を使用する場合は dedicated-admin ロールを持つアカウント。

手順

  1. OpenTelemetry Collector インスタンスのプロジェクトを作成します。

    apiVersion: project.openshift.io/v1
    kind: Project
    metadata:
      name: observability
    Copy to Clipboard Toggle word wrap
  2. サービスアカウントを作成します。

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: otel-collector-sidecar
      namespace: observability
    Copy to Clipboard Toggle word wrap
  3. k8sattributes および resourcedetection プロセッサーの権限をサービスアカウントに付与します。

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: otel-collector
    rules:
    - apiGroups: ["", "config.openshift.io"]
      resources: ["pods", "namespaces", "infrastructures", "infrastructures/status"]
      verbs: ["get", "watch", "list"]
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: otel-collector
    subjects:
    - kind: ServiceAccount
      name: otel-collector-sidecar
      namespace: observability
    roleRef:
      kind: ClusterRole
      name: otel-collector
      apiGroup: rbac.authorization.k8s.io
    Copy to Clipboard Toggle word wrap
  4. OpenTelemetry Collector をサイドカーとしてデプロイします。

    apiVersion: opentelemetry.io/v1beta1
    kind: OpenTelemetryCollector
    metadata:
      name: otel
      namespace: observability
    spec:
      serviceAccount: otel-collector-sidecar
      mode: sidecar
      config:
        serviceAccount: otel-collector-sidecar
        receivers:
          otlp:
            protocols:
              grpc: {}
              http: {}
        processors:
          batch: {}
          memory_limiter:
            check_interval: 1s
            limit_percentage: 50
            spike_limit_percentage: 30
          resourcedetection:
            detectors: [openshift]
            timeout: 2s
        exporters:
          otlp:
            endpoint: "tempo-<example>-gateway:8090" 
    1
    
            tls:
              insecure: true
        service:
          pipelines:
            traces:
              receivers: [otlp]
              processors: [memory_limiter, resourcedetection, batch]
              exporters: [otlp]
    Copy to Clipboard Toggle word wrap
    1
    これは、<example> Tempo Operator を使用してデプロイされた TempoStack インスタンスのゲートウェイを指します。
  5. otel-collector-sidecar サービスアカウントを使用してデプロイメントを作成します。
  6. sidecar.opentelemetry.io/inject: "true" アノテーションを Deployment オブジェクトに追加します。これにより、ワークロードから OpenTelemetry Collector インスタンスにデータを送信するために必要なすべての環境変数が注入されます。

1.2. サイドカー注入を使用せずにトレースとメトリクスを OpenTelemetry Collector に送信する

サイドカー注入を使用せずに、テレメトリーデータを OpenTelemetry Collector インスタンスに送信するようにセットアップできます。これには、いくつかの環境変数を手動で設定する必要があります。

前提条件

  • Red Hat OpenShift distributed tracing platform (Tempo) がインストールされ、TempoStack インスタンスがデプロイされている。
  • Web コンソールまたは OpenShift CLI (oc) を使用してクラスターにアクセスできる。

    • cluster-admin ロールを持つクラスター管理者として Web コンソールにログインしている。
    • cluster-admin ロールを持つクラスター管理者によるアクティブな OpenShift CLI (oc) セッション。
    • Red Hat OpenShift Dedicated を使用する場合は dedicated-admin ロールを持つアカウント。

手順

  1. OpenTelemetry Collector インスタンスのプロジェクトを作成します。

    apiVersion: project.openshift.io/v1
    kind: Project
    metadata:
      name: observability
    Copy to Clipboard Toggle word wrap
  2. サービスアカウントを作成します。

    apiVersion: v1
    kind: ServiceAccount
    metadata:
      name: otel-collector-deployment
      namespace: observability
    Copy to Clipboard Toggle word wrap
  3. k8sattributes および resourcedetection プロセッサーの権限をサービスアカウントに付与します。

    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: otel-collector
    rules:
    - apiGroups: ["", "config.openshift.io"]
      resources: ["pods", "namespaces", "infrastructures", "infrastructures/status"]
      verbs: ["get", "watch", "list"]
    ---
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: otel-collector
    subjects:
    - kind: ServiceAccount
      name: otel-collector-deployment
      namespace: observability
    roleRef:
      kind: ClusterRole
      name: otel-collector
      apiGroup: rbac.authorization.k8s.io
    Copy to Clipboard Toggle word wrap
  4. OpenTelemetryCollector カスタムリソースを使用して OpenTelemetry Collector インスタンスをデプロイします。

    apiVersion: opentelemetry.io/v1beta1
    kind: OpenTelemetryCollector
    metadata:
      name: otel
      namespace: observability
    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-<example>-distributor:4317" 
    1
    
            tls:
              insecure: true
        service:
          pipelines:
            traces:
              receivers: [jaeger, opencensus, otlp, zipkin]
              processors: [memory_limiter, k8sattributes, resourcedetection, batch]
              exporters: [otlp]
    Copy to Clipboard Toggle word wrap
    1
    これは、<example> Tempo Operator を使用してデプロイされた TempoStack インスタンスのゲートウェイを指します。
  5. 計装されたアプリケーションを使用してコンテナーに環境変数を設定します。

    Expand
    名前説明デフォルト値

    OTEL_SERVICE_NAME

    service.name リソース属性の値を設定します。

    ""

    OTEL_EXPORTER_OTLP_ENDPOINT

    オプションで指定したポート番号を持つシグナル型のベースエンドポイント URL。

    https://localhost:4317

    OTEL_EXPORTER_OTLP_CERTIFICATE

    gRPC クライアントの TLS 認証情報の証明書ファイルへのパス。

    https://localhost:4317

    OTEL_TRACES_SAMPLER

    トレースに使用されるサンプラー。

    parentbased_always_on

    OTEL_EXPORTER_OTLP_PROTOCOL

    OTLP エクスポーターのトランスポートプロトコル。

    grpc

    OTEL_EXPORTER_OTLP_TIMEOUT

    OTLP エクスポーターが各バッチエクスポートを待機する最大時間間隔。

    10s

    OTEL_EXPORTER_OTLP_INSECURE

    gRPC リクエストのクライアントトランスポートセキュリティーを無効にします。HTTPS スキーマはこれをオーバーライドします。

    False

法律上の通知

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
トップに戻る