1
0
mirror of https://github.com/openshift/openshift-docs.git synced 2026-02-05 12:46:18 +01:00
Files
openshift-docs/modules/otel-target-allocator.adoc

103 lines
3.5 KiB
Plaintext

// Module included in the following assemblies:
//
// * observability/otel/otel-collector/otel-collector-configuration-intro.adoc
:_mod-docs-content-type: REFERENCE
[id="otel-collector-target-allocator_{context}"]
= Target Allocator
[role="_abstract"]
The Target Allocator is an optional component of the OpenTelemetry Operator that shards scrape targets across the deployed fleet of OpenTelemetry Collector instances. The Target Allocator integrates with the Prometheus `PodMonitor` and `ServiceMonitor` custom resources (CR). When the Target Allocator is enabled, the OpenTelemetry Operator adds the `http_sd_config` field to the enabled `prometheus` receiver that connects to the Target Allocator service.
:FeatureName: The Target Allocator
include::snippets/technology-preview.adoc[]
.Example OpenTelemetryCollector CR with the enabled Target Allocator
[source,yaml]
----
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> When the Target Allocator is enabled, the deployment mode must be set to `statefulset`.
<2> Enables the Target Allocator. Defaults to `false`.
<3> The service account name of the Target Allocator deployment. The service account needs to have RBAC to get the `ServiceMonitor`, `PodMonitor` custom resources, and other objects from the cluster to properly set labels on scraped metrics. The default service name is `<collector_name>-targetallocator`.
<4> Enables integration with the Prometheus `PodMonitor` and `ServiceMonitor` custom resources.
<5> Label selector for the Prometheus `ServiceMonitor` custom resources. When left empty, enables all service monitors.
<6> Label selector for the Prometheus `PodMonitor` custom resources. When left empty, enables all pod monitors.
<7> Prometheus receiver with the minimal, empty `scrape_config: []` configuration option.
The Target Allocator deployment uses the Kubernetes API to get relevant objects from the cluster, so it requires a custom RBAC configuration.
.RBAC configuration for the Target Allocator service account
[source,yaml]
----
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>
# ...
----
<1> The name of the Target Allocator service account.
<2> The namespace of the Target Allocator service account.