Skip to content

Commit db15980

Browse files
authored
Update selector documentation for Target Allocator (open-telemetry#3001)
1 parent dac4774 commit db15980

File tree

5 files changed

+23
-33
lines changed

5 files changed

+23
-33
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ spec:
693693
serviceAccount: everything-prometheus-operator-needs
694694
prometheusCR:
695695
enabled: true
696+
serviceMonitorSelector: {}
697+
podMonitorSelector: {}
696698
config:
697699
receivers:
698700
prometheus:

apis/v1beta1/targetallocator_types.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ type TargetAllocatorPrometheusCR struct {
3131
// +kubebuilder:validation:Format:=duration
3232
ScrapeInterval *metav1.Duration `json:"scrapeInterval,omitempty"`
3333
// PodMonitors to be selected for target discovery.
34-
// This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
35-
// PodMonitor's meta labels. The requirements are ANDed.
34+
// A label selector is a label query over a set of resources. The result of matchLabels and
35+
// matchExpressions are ANDed. An empty label selector matches all objects. A null
36+
// label selector matches no objects.
3637
// +optional
3738
PodMonitorSelector *metav1.LabelSelector `json:"podMonitorSelector,omitempty"`
3839
// ServiceMonitors to be selected for target discovery.
39-
// This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
40-
// ServiceMonitor's meta labels. The requirements are ANDed.
40+
// A label selector is a label query over a set of resources. The result of matchLabels and
41+
// matchExpressions are ANDed. An empty label selector matches all objects. A null
42+
// label selector matches no objects.
4143
// +optional
4244
ServiceMonitorSelector *metav1.LabelSelector `json:"serviceMonitorSelector,omitempty"`
4345
}

cmd/otel-allocator/README.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -131,29 +131,8 @@ and jobs on the `/scrape_configs` and `/jobs` endpoints respectively.
131131

132132
The CRs can be filtered by labels as documented here: [api.md#opentelemetrycollectorspectargetallocatorprometheuscr](../../docs/api.md#opentelemetrycollectorspectargetallocatorprometheuscr)
133133

134-
The Prometheus Receiver in the deployed Collector also has to know where the Allocator service exists. This is done by a
135-
OpenTelemetry Collector Operator-specific config.
136-
137-
```yaml
138-
config: |
139-
receivers:
140-
prometheus:
141-
config:
142-
scrape_configs:
143-
- job_name: 'otel-collector'
144-
target_allocator:
145-
endpoint: http://my-targetallocator-service
146-
interval: 30s
147-
collector_id: "${POD_NAME}"
148-
```
149-
150134
Upstream documentation here: [PrometheusReceiver](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/prometheusreceiver#opentelemetry-operator)
151135

152-
The TargetAllocator service is named based on the `OpenTelemetryCollector` CR name. For example, if your Collector CR name is `my-collector`, then the TargetAllocator `service` and `deployment` will each be named `my-collector-targetallocator`, and the `pod` will be named `my-collector-targetallocator-<pod_id>`. `collector_id` should be unique per
153-
collector instance, such as the pod name. The `POD_NAME` environment variable is convenient since this is supplied
154-
to collector instance pods by default.
155-
156-
157136
### RBAC
158137

159138
Before the TargetAllocator can start scraping, you need to set up Kubernetes RBAC (role-based access controls) resources. This means that you need to have a `ServiceAccount` and corresponding cluster roles so that the TargetAllocator has access to all of the necessary resources to pull metrics from.

docs/api.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43103,8 +43103,9 @@ All CR instances which the ServiceAccount has access to will be retrieved. This
4310343103
<td>object</td>
4310443104
<td>
4310543105
PodMonitors to be selected for target discovery.
43106-
This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
43107-
PodMonitor's meta labels. The requirements are ANDed.<br/>
43106+
A label selector is a label query over a set of resources. The result of matchLabels and
43107+
matchExpressions are ANDed. An empty label selector matches all objects. A null
43108+
label selector matches no objects.<br/>
4310843109
</td>
4310943110
<td>false</td>
4311043111
</tr><tr>
@@ -43126,8 +43127,9 @@ Default: "30s"<br/>
4312643127
<td>object</td>
4312743128
<td>
4312843129
ServiceMonitors to be selected for target discovery.
43129-
This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
43130-
ServiceMonitor's meta labels. The requirements are ANDed.<br/>
43130+
A label selector is a label query over a set of resources. The result of matchLabels and
43131+
matchExpressions are ANDed. An empty label selector matches all objects. A null
43132+
label selector matches no objects.<br/>
4313143133
</td>
4313243134
<td>false</td>
4313343135
</tr></tbody>
@@ -43140,8 +43142,9 @@ ServiceMonitor's meta labels. The requirements are ANDed.<br/>
4314043142

4314143143

4314243144
PodMonitors to be selected for target discovery.
43143-
This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
43144-
PodMonitor's meta labels. The requirements are ANDed.
43145+
A label selector is a label query over a set of resources. The result of matchLabels and
43146+
matchExpressions are ANDed. An empty label selector matches all objects. A null
43147+
label selector matches no objects.
4314543148

4314643149
<table>
4314743150
<thead>
@@ -43224,8 +43227,9 @@ merge patch.<br/>
4322443227

4322543228

4322643229
ServiceMonitors to be selected for target discovery.
43227-
This is a map of {key,value} pairs. Each {key,value} in the map is going to exactly match a label in a
43228-
ServiceMonitor's meta labels. The requirements are ANDed.
43230+
A label selector is a label query over a set of resources. The result of matchLabels and
43231+
matchExpressions are ANDed. An empty label selector matches all objects. A null
43232+
label selector matches no objects.
4322943233

4323043234
<table>
4323143235
<thead>

docs/crd-changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ spec:
145145
key: value
146146
```
147147

148+
> [!NOTE]
149+
> A `nil` selector now selects no resources, while an empty selector selects all of them. To get the old default behaviour, it's necessary to set `serviceMonitorSelector: {}`.
150+
148151
### Default Collector image
149152

150153
The OpenTelemetry Collector maintainers recently introduced a [Collector distribution][k8s_distro] specifically aimed at

0 commit comments

Comments
 (0)