これはOpenShift Advent Calendar 2025の12/8の記事です
なぜ我々はプラットフォームのデータを集約するのか
我々が運用するプラットフォームは、Kubernetesやマイクロサービスなどの普及でプラットフォームの内部がかなり複雑化していると思います。それにより問題が起きた場合に、迅速な原因の特定が難しくなっているのでないでしょうか。
では、どうするのかと言うと、内部状態をよく理解し、原因分析できるようにObservabilityが求められます。なので、今回はOpenShiftのRed Hat build of OpenTelemetry(OTEL)を使って、テレメトリーデータを外部へ転送する方法をご紹介しようかと思います。
Red Hat build of OpenTelemetryとは
Red HatがOpeartorとして提供しているOTELになります。デプロイすることで、OpenShiftのテレメトリーデータを集取、加工、転送することができます。テレメトリデータには、ログ/メトリクス/トレースがあります。
執筆時点(2025/12/08)において、Red Hat build of OpenTelemetryはレシーバやプロセッサーなど使える機能にTechnology Previewが多くあります。利用される際は、以下の参考情報から確認してください。
参考情報
- OpenTelemetry
- Red Hat build of OpenTelemetry
- Red Hat build of OpenTelemetry レシーバー
- Red Hat build of OpenTelemetry プロセッサー
- Red Hat build of OpenTelemetry エクスポーター
今回は、これらを利用して、メトリクスとログを外部へ転送します。
実際に転送してみよう
本記事において、以下を実機で確認します。
- 外部へOpenShift上のPrometheusからメトリクスを転送する
- 外部へOpenShift上のPodのログを転送する
検証環境
- OpenShift 4.18
- Red Hat build of OpenTelemetry Operator 0.140
- OpenObserve 0.20.2
OpenObserveはOpenObserve社が開発しているOSSのObservabilityプラットフォームになります。OpenShiftからメトリクスデータを転送するための外部宛先として、このソフトウェアを使用します。
手順
Red Hat build of OpenTelemetry Operatorのインストール
OpenShiftのコンソールからOperatorをインストールしていきます。

デフォルトの値のまま、Installをクリックしていきます。

メトリクス用のOTELのデプロイ
observabilityのnamespaceを作成します。
oc create ns observability
OpenTelemetryCollectorForMetrics.yamlを作成します。
piVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: otel-collector
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-monitoring-view
subjects:
- kind: ServiceAccount
name: otel-collector
namespace: observability
---
kind: ConfigMap
apiVersion: v1
metadata:
name: cabundle
namespace: observability
annotations:
service.beta.openshift.io/inject-cabundle: "true"
---
apiVersion: opentelemetry.io/v1beta1
kind: OpenTelemetryCollector
metadata:
name: otel
namespace: observability
spec:
volumeMounts:
- name: cabundle-volume
mountPath: /etc/pki/ca-trust/source/service-ca
readOnly: true
volumes:
- name: cabundle-volume
configMap:
name: cabundle
mode: deployment
config:
receivers:
prometheus:
config:
scrape_configs:
- job_name: 'federate'
scrape_interval: 15s
scheme: https
tls_config:
ca_file: /etc/pki/ca-trust/source/service-ca/service-ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
honor_labels: false
params:
'match[]':
- '{job="kubelet"}'
metrics_path: '/federate'
static_configs:
- targets:
- "prometheus-k8s.openshift-monitoring.svc.cluster.local:9091"
exporters:
otlphttp:
endpoint: http://192.168.100.201:5080/api/default
headers:
Authorization: "<YOUR TOKEN>"
organization: default
stream-name: default
tls:
insecure: true
service:
pipelines:
metrics:
receivers: [prometheus]
processors: []
exporters: [otlphttp]
上記をデプロイします。
oc apply -f OpenTelemetryCollectorForMetrics.yaml
OpenObserveからOpenShiftへ転送されたメトリクスを確認します。

ログ用のOTELのデプロイ
次にログ用のOTELをデプロイします。別のnamespaceを作成します。
oc create ns openshift-logging
OpenTelemetryCollectorForLogs.yamlを作成します。
apiVersion: v1
kind: ServiceAccount
metadata:
name: otel-collector-deployment
namespace: openshift-logging
---
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"]
---
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
---
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:
- 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: http://192.168.100.201:5080/api/default
headers:
Authorization: "<YOUR TOKEN>"
organization: default
stream-name: default
tls:
insecure: true
service:
extensions: [bearertokenauth]
pipelines:
logs:
receivers: [otlp]
processors: [k8sattributes, transform, resource]
exporters: [otlphttp]
上記をデプロイします。
oc apply -f OpenTelemetryCollectorForLogs.yaml
ログを出力するテスト用のJobを作成します。
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
テスト用のJobをデプロイします。
oc apply -f test.yaml
再度ログが転送されているかOpenObserveを確認します。
まとめ
Red Hat build of OpenTelemetryを使って、OpenShiftのメトリクスやログを転送してみました。今回はOSSのOpenObserveを使いましたが、SaaSがOTLP/gRPCやOTLP/HTTPに対応していれば、簡単にOpenShiftのテレメトリデータが転送できるかもしれないです。



