第6章 OpenTelemetry Collector へのトレース、ログ、メトリクスの送信
Red Hat build of OpenTelemetry をセットアップして使用し、トレース、ログ、メトリクスを OpenTelemetry Collector または TempoStack インスタンスに送信できます。
OpenTelemetry Collector へのトレースとメトリクスの送信は、サイドカーインジェクションの有無にかかわらず可能です。
6.1. サイドカーインジェクションを使用してトレースとメトリクスを OpenTelemetry Collector に送信する リンクのコピーリンクがクリップボードにコピーされました!
サイドカーインジェクションを使用して、OpenTelemetry Collector インスタンスへのテレメトリーデータの送信をセットアップできます。
Red Hat build of OpenTelemetry Operator では、デプロイメントワークロードへのサイドカーインジェクションと、OpenTelemetry Collector にテレメトリーデータを送信するための計装の自動設定が可能です。
前提条件
- Red Hat OpenShift Distributed Tracing Platform がインストールされ、TempoStack インスタンスがデプロイされている。
Web コンソールまたは OpenShift CLI (
oc) を使用してクラスターにアクセスできる。-
cluster-adminロールを持つクラスター管理者として Web コンソールにログインしている。 -
cluster-adminロールを持つクラスター管理者によるアクティブな OpenShift CLI (oc) セッション。 -
Red Hat OpenShift Dedicated の場合、
dedicated-adminロールを持つアカウントがある。
-
手順
OpenTelemetry Collector インスタンスのプロジェクトを作成します。
apiVersion: project.openshift.io/v1 kind: Project metadata: name: observabilityサービスアカウントを作成します。
apiVersion: v1 kind: ServiceAccount metadata: name: otel-collector-sidecar namespace: observabilityk8sattributesおよび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.ioOpenTelemetry 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]- 1
- これは、
<example>Tempo Operator を使用してデプロイされた TempoStack インスタンスのゲートウェイを指します。
-
otel-collector-sidecarサービスアカウントを使用してデプロイメントを作成します。 -
sidecar.opentelemetry.io/inject: "true"アノテーションをDeploymentオブジェクトに追加します。これにより、ワークロードから OpenTelemetry Collector インスタンスにデータを送信するために必要なすべての環境変数が注入されます。