This is a cache of https://docs.openshift.com/container-platform/4.15/observability/otel/otel-collector/otel-collector-target-allocator.html. It is a snapshot of the page at 2024-11-27T13:00:34.636+0000.
Target Allocator - Red Hat build of OpenTelemetry | Observability | OpenShift Container Platform 4.15
×

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.

The Target Allocator is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

Example OpenTelemetryCollector CR with the enabled Target Allocator
apiVersion: opentelemetry.io/v1alpha1
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
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: otel-targetallocator
rules:
  - apiGroups: [""]
    resources:
      - services
      - pods
    verbs: ["get", "list", "watch"]
  - apiGroups: ["monitoring.coreos.com"]
    resources:
      - servicemonitors
      - podmonitors
    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 mane.
2 The namespace of the Target Allocator service account.