Skip to content

Commit ffc8da6

Browse files
committed
Add documentation about the TA CRD
1 parent 6e879c1 commit ffc8da6

File tree

2 files changed

+126
-0
lines changed

2 files changed

+126
-0
lines changed

cmd/otel-allocator/README.md

+46
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ The easiest way to do this is to grab a copy of the individual [`PodMonitor`](ht
8686
> ✨ For more information on configuring the `PodMonitor` and `ServiceMonitor`, check out the [PodMonitor API](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#monitoring.coreos.com/v1.PodMonitor) and the [ServiceMonitor API](https://github.com/prometheus-operator/prometheus-operator/blob/main/Documentation/api.md#monitoring.coreos.com/v1.ServiceMonitor).
8787
8888
# Usage
89+
8990
The `spec.targetAllocator:` controls the TargetAllocator general properties. Full API spec can be found here: [api.md#opentelemetrycollectorspectargetallocator](../../docs/api.md#opentelemetrycollectorspectargetallocator)
9091

9192
A basic example that deploys.
@@ -122,6 +123,51 @@ In essence, Prometheus Receiver configs are overridden with a `http_sd_config` d
122123
Allocator, these are then loadbalanced/sharded to the Collectors. The [Prometheus Receiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/receiver/prometheusreceiver/README.md) configs that are overridden
123124
are what will be distributed with the same name.
124125

126+
## TargetAllocator CRD
127+
128+
The `spec.targetAllocator` attribute allows very limited control over the target allocator resources. More customization is possible by using
129+
the `TargetAllocator` CRD. We create the `TargetAllocator` CR, and then add its name in the `opentelemetry.io/target-allocator` label on the respective OpenTelemetryCollector CR.
130+
131+
The basic example from above looks as follows with this setup:
132+
133+
```yaml
134+
apiVersion: opentelemetry.io/v1beta1
135+
kind: OpenTelemetryCollector
136+
metadata:
137+
name: collector-with-ta
138+
labels:
139+
opentelemetry.io/target-allocator: ta
140+
spec:
141+
mode: statefulset
142+
config:
143+
receivers:
144+
prometheus:
145+
config:
146+
scrape_configs:
147+
- job_name: 'otel-collector'
148+
scrape_interval: 10s
149+
static_configs:
150+
- targets: [ '0.0.0.0:8888' ]
151+
152+
exporters:
153+
debug: {}
154+
155+
service:
156+
pipelines:
157+
metrics:
158+
receivers: [prometheus]
159+
exporters: [debug]
160+
---
161+
apiVersion: opentelemetry.io/v1alpha1
162+
kind: TargetAllocator
163+
metadata:
164+
name: ta
165+
spec:
166+
```
167+
168+
Note that the scrape configs can be specified either in the prometheus receiver configuration, or directly in the TargetAllocator CRD. The resultant
169+
target allocator will use both.
170+
125171
## PrometheusCR specifics
126172

127173
TargetAllocator discovery of PrometheusCRs can be turned on by setting

docs/crd-changelog.md

+80
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,86 @@
33
This document explains major changes made in new CRD versions. It is intended to help users migrate and take
44
advantage of the new features.
55

6+
## TargetAllocator.opentelemetry.io/v1alpha1
7+
8+
The target allocator is an application that can allocate Prometheus scrape targets to OpenTelemetry Collectors using the prometheus receiver,
9+
allowing transparent horizontal scaling for Prometheus metrics collection. You can learn more in the target allocator's [README](../cmd/otel-allocator/README.md).
10+
11+
Until now, it could be enabled via the `targetAllocator` sub-resource in the OpenTelemetryCollector CR. This was, and continues to be fine for
12+
simpler use cases. Some users needed to customize the target allocator further, and embedding all the required attributes in the
13+
OpenTelemetryCollector CR would've made it unnecessarily large. Instead, we introduced a separate CRD for the target allocator.
14+
15+
The following OpenTelemetryCollector CR:
16+
17+
```yaml
18+
apiVersion: opentelemetry.io/v1beta1
19+
kind: OpenTelemetryCollector
20+
metadata:
21+
name: simplest
22+
spec:
23+
targetAllocator:
24+
enabled: true
25+
prometheusCR:
26+
enabled: true
27+
config:
28+
receivers:
29+
prometheus:
30+
config:
31+
scrape_configs: []
32+
processors:
33+
batch:
34+
send_batch_size: 1000
35+
timeout: 10s
36+
exporters:
37+
debug: {}
38+
service:
39+
pipelines:
40+
traces:
41+
receivers: [prometheus]
42+
processors: [batch]
43+
exporters: [debug]
44+
```
45+
46+
is now equivalent to the pair:
47+
48+
```yaml
49+
apiVersion: opentelemetry.io/v1beta1
50+
kind: OpenTelemetryCollector
51+
metadata:
52+
name: simplest
53+
labels:
54+
opentelemetry.io/target-allocator: simplest-ta
55+
spec:
56+
config:
57+
receivers:
58+
prometheus:
59+
config:
60+
scrape_configs: []
61+
processors:
62+
batch:
63+
send_batch_size: 1000
64+
timeout: 10s
65+
exporters:
66+
debug: {}
67+
service:
68+
pipelines:
69+
traces:
70+
receivers: [prometheus]
71+
processors: [batch]
72+
exporters: [debug]
73+
---
74+
apiVersion: opentelemetry.io/v1alpha1
75+
kind: TargetAllocator
76+
metadata:
77+
name: simplest-ta
78+
spec:
79+
prometheusCR:
80+
enabled: true
81+
```
82+
83+
> [!NOTE]
84+
> The OpenTelemetryCollector is connected to the TargetAllocator by setting the `opentelemetry.io/target-allocator` label on the former.
85+
686
## OpenTelemetryCollector.opentelemetry.io/v1beta1
787

888
### Migration

0 commit comments

Comments
 (0)