apiVersion: project.openshift.io/v1
kind: Project
metadata:
name: observability
您可以设置和使用 Red Hat 版本的 OpenTelemetry 将跟踪发送到 OpenTelemetry Collector 或 TempoStack 实例。
可以使用或不使用 Sidecar 注入将跟踪和指标发送到 OpenTelemetry Collector。
您可以设置将遥测数据发送到具有 Sidecar 注入的 OpenTelemetry Collector 实例。
Red Hat 版本的 OpenTelemetry Operator 允许将 Sidecar 注入到部署工作负载中,并自动配置您的检测以将遥测数据发送到 OpenTelemetry Collector。
已安装 Red Hat OpenShift 分布式跟踪平台 (Tempo),并部署了 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: observability
授予服务帐户对 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
将 OpenTelemetry Collector 部署为 Sidecar。
apiVersion: opentelemetry.io/v1alpha1
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: [jaeger]
processors: [memory_limiter, resourcedetection, batch]
exporters: [otlp]
1 | 这指向使用 <example> Tempo Operator 部署的 TempoStack 实例的网关。 |
使用 otel-collector-sidecar
服务帐户创建您的部署。
将 sidecar.opentelemetry.io/inject: "true"
注解添加到您的 Deployment
对象。这将注入所有必要的环境变量,以便将数据从您的工作负载发送到 OpenTelemetry Collector 实例。
您可以设置将遥测数据发送到不使用 Sidecar 注入的 OpenTelemetry Collector 实例,这涉及手动设置多个环境变量。
已安装 Red Hat OpenShift 分布式跟踪平台 (Tempo),并部署了 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-deployment
namespace: observability
授予服务帐户对 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
使用 OpenTelemetryCollector
自定义资源部署 OpenTelemetry Collector 实例。
apiVersion: opentelemetry.io/v1alpha1
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]
1 | 这指向使用 <example> Tempo Operator 部署的 TempoStack 实例的网关。 |
在包含您已检测应用程序的容器中设置环境变量。
名称 | 描述 | 默认值 |
---|---|---|
|
设置 |
|
|
任何信号类型的基本端点 URL,并可以选择指定端口号。 |
|
|
gRPC 客户端 TLS 证书文件的路径。 |
|
|
用于跟踪的采样器。 |
|
|
OTLP 导出器的传输协议。 |
|
|
OTLP 导出器等待每次批量导出所需的最大时间间隔。 |
|
|
禁用 gRPC 请求的客户端传输安全性。HTTPS 模式会覆盖它。 |
|