3.7. 目标分配器
目标分配器是 OpenTelemetry Operator 的一个可选组件,它会在部署的 OpenTelemetry Collector 实例间分片提取目标。目标分配器与 Prometheus PodMonitor
和 ServiceMonitor
自定义资源 (CR) 集成。启用目标分配器时,OpenTelemetry Operator 会将 http_sd_config
字段添加到连接到目标分配器服务的启用的 prometheus
接收器。
重要
目标分配器只是一个技术预览功能。技术预览功能不受红帽产品服务等级协议(SLA)支持,且功能可能并不完整。红帽不推荐在生产环境中使用它们。这些技术预览功能可以使用户提早试用新的功能,并有机会在开发阶段提供反馈意见。
有关红帽技术预览功能支持范围的更多信息,请参阅技术预览功能支持范围。
带有启用的 Target Allocator 的 OpenTelemetryCollector CR 示例
apiVersion: opentelemetry.io/v1beta1 kind: OpenTelemetryCollector metadata: name: otel namespace: observability spec: mode: statefulset 1 targetAllocator: enabled: true 2 serviceAccount: 3 prometheusCR: enabled: true 4 scrapeInterval: 10s serviceMonitorSelector: 5 name: app1 podMonitorSelector: 6 name: app2 config: receivers: prometheus: 7 config: scrape_configs: [] processors: exporters: debug: {} service: pipelines: metrics: receivers: [prometheus] processors: [] exporters: [debug] # ...
- 1
- 启用 Target Allocator 时,部署模式必须设置为
statefulset
。 - 2
- 启用目标分配器。默认值为
false
。 - 3
- Target Allocator 部署的服务帐户名称。服务帐户需要具有 RBAC 才能从集群中获取
ServiceMonitor
、PodMonitor
自定义资源和其他对象,以便在提取的指标上正确设置标签。默认服务名称为<collector_name>-targetallocator
。 - 4
- 启用与 Prometheus
PodMonitor
和ServiceMonitor
自定义资源集成。 - 5
- Prometheus
ServiceMonitor
自定义资源的标签选择器。当留空时,请启用所有服务监视器。 - 6
- Prometheus
PodMonitor
自定义资源的标签选择器。留空时,启用所有 pod 监视器。 - 7
- Prometheus 接收器带有 minimal, empty
scrape_config: []
配置选项。
Target Allocator 部署使用 Kubernetes API 从集群中获取相关对象,因此它需要自定义 RBAC 配置。
目标 Allocator 服务帐户的 RBAC 配置
apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: otel-targetallocator rules: - apiGroups: [""] resources: - services - pods - namespaces verbs: ["get", "list", "watch"] - apiGroups: ["monitoring.coreos.com"] resources: - servicemonitors - podmonitors - scrapeconfigs - probes verbs: ["get", "list", "watch"] - apiGroups: ["discovery.k8s.io"] resources: - endpointslices verbs: ["get", "list", "watch"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: otel-targetallocator roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: otel-targetallocator subjects: - kind: ServiceAccount name: otel-targetallocator 1 namespace: observability 2 # ...